In my app I am uploading images to AWS via Retrofit with this code:
private interface UploadFileToAwsInterface {
@Multipart
@POST("/")
SuccessResponse uploadFile(@Part("key") String key,
@Part("AWSAccessKeyId") String AWSAccessKeyId,
@Part("acl") String acl,
@Part("success_action_redirect") String success_action_redirect,
@Part("policy") String policy,
@Part("signature") String signature,
@Part("utf8") String utf8,
@Part("Content-Type") String contType,
@Part("file") TypedFile file);
}
public Boolean uploadFileToAws(AWSCredentials awsCredentials, File localFile, String mimeType) {
TypedFile file = new TypedFile(mimeType, localFile);
endPoint.setUrl(awsCredentials.getAction());
UploadFileToAwsInterface uploadFileInterface = restAdapter.create(UploadFileToAwsInterface.class);
SuccessResponse response = uploadFileInterface.uploadFile(
awsCredentials.getKey(),
awsCredentials.getAWSAccessKeyId(),
awsCredentials.getAcl(),
awsCredentials.getSuccess_action_redirect(),
awsCredentials.getPolicy(),
awsCredentials.getSignature(),
"true",
mimeType,
file);
Image uploading works fine. But when I start image upload and network disconnect, I can't get response. How I can handle such situation?
Aucun commentaire:
Enregistrer un commentaire