java - Get Request Fulfilled Response from Amazon S3 -
this code example of uploading object using amazon s3 .
public class uploadobjectsingleoperation { private static string bucketname = "*** provide bucket name ***"; private static string keyname = "*** provide key ***"; private static string uploadfilename = "*** provide file name ***"; public static void main(string[] args) throws ioexception { amazons3 s3client = new amazons3client(new profilecredentialsprovider()); try { system.out.println("uploading new object s3 file\n"); file file = new file(uploadfilename); s3client.putobject(new putobjectrequest( bucketname, keyname, file)); } catch (amazonserviceexception ase) { system.out.println("caught amazonserviceexception, " + "means request made " + "to amazon s3, rejected error response" + " reason."); system.out.println("error message: " + ase.getmessage()); system.out.println("http status code: " + ase.getstatuscode()); system.out.println("aws error code: " + ase.geterrorcode()); system.out.println("error type: " + ase.geterrortype()); system.out.println("request id: " + ase.getrequestid()); } catch (amazonclientexception ace) { system.out.println("caught amazonclientexception, " + "means client encountered " + "an internal error while trying " + "communicate s3, " + "such not being able access network."); system.out.println("error message: " + ace.getmessage()); } }
in , can http status code if amazonserviceexception. there way http status code successful response ? aim acknowledged image uploaded successfully.
find out there no way httpstatus code successful response. listening exceptions enough sure of succeeded upload .
Comments
Post a Comment