I\'m trying upload a Image
from my Android APP to Amazon AWS S3 and I need use AWS Restful API.
I\'m using Retrofit 2
You are sending a multipart payload, but forcing the Content-type to be image/jpeg
. Your jpg is corrupt because S3 probably saved the multipart headers into your jpg file since you told it the whole message was a JPG. Since you do not actually have multiple parts to send, you can drop the Multipart
annotation and use Body
instead of Part
for your RequestBody
public interface AwsS3 {
@PUT("/{Key}")
Call upload(@Path("Key") String Key,
@Header("Content-Length") long length,
@Header("Accept") String accept,
@Header("Host") String host,
@Header("Date") String date,
@Header("Content-type") String contentType,
@Header("Authorization") String authorization,
@Body RequestBody body);
}
You should also be able to remove explicitly setting the Content-type
and Content-length
headers.