GET upload/media STATUS on images -

api

#1

Hey there,

I’m seeing a weird situation in my Ruby code with chunked uploads. It handles video properly, but fails to upload images.

The code has a lot of abstractions in it so I’ll try to get across what I’m doing without posting it. :confused: The working video upload code does this:

POST /media/upload INIT total_bytes=<XXX> media_type=<"video/mp4"> media_category=<tweet_video>
returns  {:media_id=>853991866156679168, :media_id_string=>"853991866156679168", :expires_after_secs=>86400}

POST /media/upload APPEND media_id=<media_id> media_data=<chunked_data> segment_index=<X> key<media>
(returns no body content. Repeat as needed to upload entire video in 5MB chunks)

POST /media/upload FINALIZE media_id=<media_id>
returns {:media_id=>853991866156679168, :media_id_string=>"853991866156679168", :size=>19204789, :expires_after_secs=>86400, :processing_info=>{:state=>"pending", :check_after_secs=>5}}

poll GET /media/upload STATUS media_id=<media_id>
First time: returns {:media_id=>853991866156679168, :media_id_string=>"853991866156679168", :processing_info=>{:state=>"in_progress", :check_after_secs=>5, :progress_percent=>5}} 
Second time: returns same
Third time: returns {:media_id=>853991866156679168, :media_id_string=>"853991866156679168", :size=>19204789, :expires_after_secs=>86398, :video=>{:video_type=>"video/mp4"}, :processing_info=>{:state=>"succeeded", :progress_percent=>100}}

I can then post an update with the media_id, and everything works great.

However, when I attempt to do something similar with an image, the final step (STATUS) fails, even though the update seems to work fine.

POST /media/upload INIT total_bytes=<XXX> media_type=<"image/jpeg"> media_category=<tweet_image>
returns {:media_id=>853984394205437952, :media_id_string=>"853984394205437952", :expires_after_secs=>86400} 

POST /media/upload APPEND media_id=<media_id> media_data=<chunked_data> segment_index=<X> key<media>
(returns no body content. Repeat as needed to upload entire video in 5MB chunks)

POST /media/upload FINALIZE media_id=<media_id>
{:media_id=>853984394205437952, :media_id_string=>"853984394205437952", :size=>1175899, :expires_after_secs=>86400, :image=>{:image_type=>"image/jpeg", :w=>3024, :h=>3022}}

poll GET /media/upload STATUS media_id=<media_id>
Gives me a 400/invalid mediaId.

My question is: Am I not supposed to do a STATUS on images? I can skip that step for image media_category, but it seems weird to be getting this error.

The jpg seems to meet all the image requirements and I’m able to upload the same image manually on the website, so shouldn’t have, e.g., a size issue or corruption.

Thanks!
.mike