java - Where can I find WORKING samples of Amazon's S3 Image Upload Code for Android -
i have spent past 2 days struggling amazon's s3 sdk android. able java 1 (in eclipse) working without problems whatsoever; upload pictures, download them, , no problem. changing gears android, however, , have had no luck. currently, selected code:
amazons3client s3 = new amazons3client( new basicawscredentials( constants.aws_access_key, constants.aws_secret_access_key ) ); //these correct, have confirmed. objectmetadata metadata = new objectmetadata(); metadata.setcontenttype("jpeg"); //binary data putobjectrequest putobjectrequest = new putobjectrequest( constants.bucketname, constants.key3, new file(selectedimageuri.getpath()) ); //selectedimageuri correct well, //(file:///storage/emulated/0/mydir/image_1437585138776.jpg) putobjectrequest.setmetadata(metadata); s3.putobject(putobjectrequest); //errors out here
i getting multiple errors, common of this:
amazonhttpclient﹕ unable execute http request: write error: ssl=0xb8cefc10: i/o error during system call, connection reset peer javax.net.ssl.sslexception: write error: ssl=0xb8cefc10: i/o error during system call, connection reset peer @ com.android.org.conscrypt.nativecrypto.ssl_write(native method)
i have done ton of research , had no luck finding working code. used link amazon: https://aws.amazon.com/articles/sdks/android/3002109349624271 without working me @ all. top deprecated, cannot find links working code. if follow sdk links 'android sample code' files, github repo (here: https://github.com/awslabs/aws-sdk-android-samples) contains 0 code on topic of uploading files (namely pictures).
does have idea can find working code shows how upload stupid picture bucket?!??! (wish knew why simple in java/ eclipse , not in android / studio).
ps: have api_key in correct assets folder, credentials correct login, image under 5mb, , being run on background (async) thread not on main thread.
-pat
have tested see file:///storage/emulated/0/mydir/image_1437585138776.jpg useable file? content uri android not typically map file , typically used content resolvers. double check file path , not content resolver uri path, looks like.
if pans out, double check internet connection of device. can call aws api? behind kind of firewall or protected wifi?
finally not secure use embedded credentials in android app (understandable if testing locally, never ship app embedded credentials, instead use amazon cognito authenticate). other example s3 can see getting started guide http://docs-aws.amazon.com/mobile/sdkforandroid/developerguide/getting-started-android.html has bunch of s3 example. , s3 sample on github (which updated on july 22nd) has s3 uploader sample using transfer utility, , step-by-step tutorial along it.
hope helps!
Comments
Post a Comment