Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
gdata ruby wrapper - broken image upload
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Leonardo Borges  
View profile  
 More options May 6 2009, 11:14 am
From: Leonardo Borges <leonardo.j...@gmail.com>
Date: Wed, 6 May 2009 08:14:34 -0700 (PDT)
Local: Wed, May 6 2009 11:14 am
Subject: gdata ruby wrapper - broken image upload
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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeff Fisher  
View profile  
 More options May 6 2009, 1:08 pm
From: Jeff Fisher <api.jfis...@google.com>
Date: Wed, 6 May 2009 10:08:19 -0700
Local: Wed, May 6 2009 1:08 pm
Subject: Re: [PWA API] gdata ruby wrapper - broken image upload

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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leonardo Borges Barbosa  
View profile  
 More options May 6 2009, 2:32 pm
From: Leonardo Borges Barbosa <leonardo.j...@gmail.com>
Date: Wed, 6 May 2009 20:32:30 +0200
Local: Wed, May 6 2009 2:32 pm
Subject: Re: [PWA API] Re: gdata ruby wrapper - broken image upload

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:i n
`exception'
    from
/opt/local/lib/ruby/gems/1.8/gems/gdata-1.1.0/lib/gdata/client/base.rb:89:i n
`raise'
    from
/opt/local/lib/ruby/gems/1.8/gems/gdata-1.1.0/lib/gdata/client/base.rb:89:i n
`make_request'
    from
/opt/local/lib/ruby/gems/1.8/gems/gdata-1.1.0/lib/gdata/client/base.rb:64:i n
`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]

  DSC03698.JPG
284K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeff Fisher  
View profile  
 More options May 6 2009, 3:53 pm
From: Jeff Fisher <api.jfis...@google.com>
Date: Wed, 6 May 2009 12:53:13 -0700
Local: Wed, May 6 2009 3:53 pm
Subject: Re: [PWA API] Re: gdata ruby wrapper - broken image upload

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 <


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leonardo Borges Barbosa  
View profile  
 More options May 6 2009, 4:43 pm
From: Leonardo Borges Barbosa <leonardo.j...@gmail.com>
Date: Wed, 6 May 2009 22:43:07 +0200
Local: Wed, May 6 2009 4:43 pm
Subject: Re: [PWA API] Re: gdata ruby wrapper - broken image upload

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/albu...",
@body=#<File:DSC03698.JPG>, @headers={"Slug"=>"DSC03698.JPG",
"Authorization"=>"GoogleLogin
auth=DQAAAHcAAABin-tFCqAN96yAfnDUqaBFBeU4g3r3C4Cogi9gajT9eV9LBenYIy3bpyj-SB y6xro4E8htvuMehmjfuQw8KpjVXS0fYDOjiW1k1bv1aAVJE_BOO5DvOGvtvBGEV1Anu610EL9IT wbyAxBIRrt2DGlV_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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeff Fisher  
View profile  
 More options May 7 2009, 8:23 pm
From: Jeff Fisher <api.jfis...@google.com>
Date: Thu, 7 May 2009 17:23:23 -0700
Local: Thurs, May 7 2009 8:23 pm
Subject: Re: [PWA API] Re: gdata ruby wrapper - broken image upload

Well you don't want to buffer the whole file into memory (think about when
you are uploading a 800MB YouTube file.) So what happens here is the
request's body property is set to a File object, like you noticed, but then
in default_service.rb:

case request.body
when String
  req.body = request.body
when Hash
  req.set_form_data(request.body)
when File
  req.body_stream = request.body
  request.chunked = true
when GData::HTTP::MimeBody
  req.body_stream = request.body
  request.chunked = true
else
  req.body = request.body.to_s
end

Notice that when the body is a File object, we set the body_stream to be the
file object and tell it to use chunked encoding. This causes Net::HTTP to
read from that file object when sending its request.

So I don't think this is the bug, though it could be there is some bug with
how Net::HTTP is doing the chunked encoding that is broken for 1.8.7.

Cheers,
-Jeff

On Wed, May 6, 2009 at 1:43 PM, Leonardo Borges Barbosa <


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leonardo Borges Barbosa  
View profile  
 More options May 8 2009, 2:12 am
From: Leonardo Borges Barbosa <leonardo.j...@gmail.com>
Date: Fri, 8 May 2009 08:12:22 +0200
Local: Fri, May 8 2009 2:12 am
Subject: Re: [PWA API] Re: gdata ruby wrapper - broken image upload

Tks for the update Jeff.

I'm gonna keep on digging to see if I can find the root cause of it in
1.8.7.

regards,
Leonardo Borges
www.leonardoborges.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeff Fisher  
View profile  
 More options May 8 2009, 2:15 pm
From: Jeff Fisher <api.jfis...@google.com>
Date: Fri, 8 May 2009 11:15:55 -0700
Local: Fri, May 8 2009 2:15 pm
Subject: Re: [PWA API] Re: gdata ruby wrapper - broken image upload

Yeah, it's odd that it's only reading part of the file before giving up (as
evidenced by your partial images on PWA.) I'm suspicious of it being
something inside of Net::HTTP since literally all we are doing is putting
the file contents as body_stream and telling it to chunk it. Maybe strip
down everything to just using Net::HTTP directly and have it post an image
to somewhere that you can Wireshark the request and see what it's doing
wrong.

Cheers,
-Jeff

On Thu, May 7, 2009 at 11:12 PM, Leonardo Borges Barbosa <


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leonardo Borges Barbosa  
View profile  
 More options May 8 2009, 7:44 pm
From: Leonardo Borges Barbosa <leonardo.j...@gmail.com>
Date: Sat, 9 May 2009 01:44:17 +0200
Local: Fri, May 8 2009 7:44 pm
Subject: Re: [PWA API] Re: gdata ruby wrapper - broken image upload

Actually I get a 'Not a valid image' response.  The partial images had to do
with the conenction at work.

Still haven't found what the problem is.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »