Jeff, I believe I found another bug. After I sent you my last email I went
digging in gdata's source code and found the reason for that specific
exception.

In lib/gdata/client/base.rb, method make_file_request, the line 64 reads
like this:
          response = self.make_request(method, url, file)

This causes this request to be sent:
<GData::HTTP::Request:0x15ad8a8 @url="
http://picasaweb.google.com/data/feed/api/user/leonardoborges.rj/albumid/5332810669099119713";,
@body=#<File:DSC03698.JPG>, @headers={"Slug"=>"DSC03698.JPG",
"Authorization"=>"GoogleLogin
auth=DQAAAHcAAABin-tFCqAN96yAfnDUqaBFBeU4g3r3C4Cogi9gajT9eV9LBenYIy3bpyj-SBy6xro4E8htvuMehmjfuQw8KpjVXS0fYDOjiW1k1bv1aAVJE_BOO5DvOGvtvBGEV1Anu610EL9ITwbyAxBIRrt2DGlV_XpBk8dRR8f0JPJctrWYNQ",
"Content-Type"=>"image/jpeg",
"User-Agent"=>"GoogleDataRubyUtil-AnonymousApp", "Content-Length"=>588,
"GData-Version"=>"1"}, @method=:post>

If you look at the body, it contains the default representation of the
method inspect from the object File, instead of the actual data.
Changing the line to:
          response = self.make_request(method, url, file.read)
does the trick. I've just successfully upload the picture.

If this is really a bug, I can fill in a patch request. Just let me know.

Tks,
Leonardo Borges
www.leonardoborges.com


On Wed, May 6, 2009 at 9:53 PM, Jeff Fisher <api.jfis...@google.com> wrote:

> Well, it seems you have found one bug - the exception code which was
> recently revamped in a patch missed a case. This is fixed now:
>
> http://code.google.com/p/gdata-ruby-util/source/detail?r=29
>
> But I'm still unable to reproduce your error. I uploaded the file you gave
> successfully. I'm using the stock Ruby with Leopard which seems to be ruby
> 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
>
> Can you dig into Wireshark and see what it is sending in the request?
>
> Cheers,
> -Jeff
>
>
> On Wed, May 6, 2009 at 11:32 AM, Leonardo Borges Barbosa <
> leonardo.j...@gmail.com> wrote:
>
>> Hi Jeff,
>>
>> I was trying that for a project at work so I just got home and tried the
>> same code with the attached image - which is bigger - and I'm getting this:
>>
>> NoMethodError: undefined method `status_code' for "Not a valid
>> image.":String
>>     from
>> /opt/local/lib/ruby/gems/1.8/gems/gdata-1.1.0/lib/gdata/client.rb:50:in
>> `initialize'
>>     from
>> /opt/local/lib/ruby/gems/1.8/gems/gdata-1.1.0/lib/gdata/client/base.rb:89:in
>> `exception'
>>     from
>> /opt/local/lib/ruby/gems/1.8/gems/gdata-1.1.0/lib/gdata/client/base.rb:89:in
>> `raise'
>>     from
>> /opt/local/lib/ruby/gems/1.8/gems/gdata-1.1.0/lib/gdata/client/base.rb:89:in
>> `make_request'
>>     from
>> /opt/local/lib/ruby/gems/1.8/gems/gdata-1.1.0/lib/gdata/client/base.rb:64:in
>> `make_file_request'
>>     from
>> /opt/local/lib/ruby/gems/1.8/gems/gdata-1.1.0/lib/gdata/client/base.rb:123:in
>> `post_file'
>>     from ./picasa.rb:54:in `up_photo'
>>     from (irb):7
>>     from /opt/local/lib/ruby/site_ruby/1.8/rubygems/exceptions.rb:75
>>
>> As a side node, the attached image is in one of my albums as well, so it's
>> a valid image.
>>
>> Thanks
>> PS: This is my ruby version:
>> ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9]
>>
>>
>> On Wed, May 6, 2009 at 7:08 PM, Jeff Fisher <api.jfis...@google.com>wrote:
>>
>>> Very strange. I just verified I could upload a large image (since the
>>> test image is minuscule) and it worked with a 5100×3338 pixel image. Can you
>>> e-mail me an image that is failing for you? Also it might help to know what
>>> version of Ruby you are running.
>>>
>>> Cheers,
>>> -Jeff
>>>
>>>
>>> On Wed, May 6, 2009 at 8:14 AM, Leonardo Borges <leonardo.j...@gmail.com
>>> > wrote:
>>>
>>>>
>>>> Hey guys, I've searched the knowledge base about this issue but didn't
>>>> find a suitable answer yet.
>>>>
>>>> Using ruby with the gdata gem, I'm able to list all albums in my
>>>> account, get information like title, number of photos and etc.
>>>>
>>>> I am also able to create new albums perfectly but when I try to upload
>>>> any picture, this is how my album looks like:
>>>> http://picasaweb.google.com/leonardoborges.rj/TestAlbum
>>>>
>>>> As you can see, seems like the data was not properly transmitted over
>>>> the web.
>>>>
>>>> This is how my upload code looks like: - pretty much taken from the
>>>> test case
>>>> def up_photo(test_image)
>>>>    mime_type = 'image/jpeg'
>>>>
>>>>    response = @@client.post_file(@@atom_url,
>>>>      test_image, mime_type).to_xml
>>>>
>>>>    puts response
>>>> end
>>>>
>>>> And in the following link you can check the contents of the response I
>>>> get after uploading the picture:
>>>> http://pastie.org/470038
>>>>
>>>> Am I missing something?
>>>>
>>>>
>>>> PS: The image is below the 20MB limit.
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Picasa Web Albums API" group.
To post to this group, send email to Google-Picasa-Data-API@googlegroups.com
To unsubscribe from this group, send email to 
google-picasa-data-api+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Picasa-Data-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to