Not able to upload photos bigger then about 0.5 Mb using statuses/update_with_media


#1

If asking help/configuration and it states a photo_size_limit of about 3 Mb but when I try to upload photos bigger then about 0.5 Mb using statuses/update_with_media it fails. Smaller images works just fine.

I have also tried to use the Twitter native app downloaded from Google Play and it also fails to upload the bigger images without any informative user error message.

I am using Twitter4J lib and here is the stack trace:
W/System.err( 5483): Caused by: java.net.SocketException: sendto failed: EPIPE (Broken pipe)
W/System.err( 5483): at libcore.io.IoBridge.maybeThrowAfterSendto(IoBridge.java:517)
W/System.err( 5483): at libcore.io.IoBridge.sendto(IoBridge.java:486)
W/System.err( 5483): at java.net.PlainSocketImpl.write(PlainSocketImpl.java:508)
W/System.err( 5483): at java.net.PlainSocketImpl.access$100(PlainSocketImpl.java:46)
W/System.err( 5483): at java.net.PlainSocketImpl$PlainSocketOutputStream.write(PlainSocketImpl.java:270)
W/System.err( 5483): at java.io.ByteArrayOutputStream.writeTo(ByteArrayOutputStream.java:231)
W/System.err( 5483): at libcore.net.http.RetryableOutputStream.writeToSocket(RetryableOutputStream.java:70)
W/System.err( 5483): at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:806)
W/System.err( 5483): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:274)
W/System.err( 5483): at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:486)
W/System.err( 5483): at twitter4j.internal.http.HttpResponseImpl.(HttpResponseImpl.java:35)
W/System.err( 5483): at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:164)
W/System.err( 5483): … 8 more
W/System.err( 5483): Caused by: libcore.io.ErrnoException: sendto failed: EPIPE (Broken pipe)
W/System.err( 5483): at libcore.io.Posix.sendtoBytes(Native Method)
W/System.err( 5483): at libcore.io.Posix.sendto(Posix.java:146)
W/System.err( 5483): at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:177)
W/System.err( 5483): at libcore.io.IoBridge.sendto(IoBridge.java:484)
W/System.err( 5483): … 18 more

Anyone else that face the same problems?


#2

Hi @semmelway, I was not able to reproduce this issue. I used the following code, derived from [node:1059] (which has a few inaccuracies, written as it was for API v1. Current docs are at [node:9708].

Note, this code requires https://github.com/themattharris/tmhOAuth

<?php

require ‘tmhOAuth/tmhOAuth.php’;
$tmhOAuth = new tmhOAuth(array(
‘consumer_key’ => ‘CONSUMER_KEY’,
‘consumer_secret’ => ‘CONSUMER_SECRET’,
‘user_token’ => ‘USER_TOKEN’,
‘user_secret’ => ‘USER_SECRET’,
));

// we’re using a hardcoded image path here. You can easily replace this with an uploaded image-see images.php example)
// 'image = “@{$_FILES[‘image’][‘tmp_name’]};type={$_FILES[‘image’][‘type’]};filename={$_FILES[‘image’][‘name’]}”,

$image = ‘./LARGE_IMAGE_FILENAME.jpg’;

$code = $tmhOAuth->request(‘POST’, ‘https://api.twitter.com/1.1/statuses/update_with_media.json’,
array(
‘media[]’ => “@{$image}”,
‘status’ => “A pithy comment on my photo.”
),
true, // use auth
true // multipart
);

Using this code I was able to post a 3.1 MB image without issue. See https://twitter.com/c_r_w/status/347772846833016832. :slight_smile:

I was not able to try an upload with Android, it may be worth checking out the mobile forums on that issue.


#3

Thanks for response Craig.

Yes, it seems like this is some kind of Android-Twitter issue. I will try to put more effort to unalize it.