在 AWS android 改造上上传文件时出错
Error uploading file on AWS android retrofit
当我调用 API 时,我得到一个 AWS S3 存储桶 URL
在 s3 URL 我正在尝试通过改造上传文件
但是我收到以下错误
<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message><AWSAccessKeyId>AKIA6F7T6E47MWT7QUOT</AWSAccessKeyId><StringToSign>PUT
multipart/form-data; boundary=754bc465-aad0-41d4-8ac2-2f333ec2c011
1642929217
/plnms-devappmedia/payment-receipt/252ec59e-0947-42e9-9d11-dd8f7eca0902.jpg</StringToSign><SignatureProvided>mcUVkLkJCtrlG5E0X+9uG3Yh5QA=</SignatureProvided><StringToSignBytes>50 55 54 0a 0a 6d 75 6c 74 69 70 61 72 74 2f 66 6f 72 6d 2d 64 61 74 61 3b 20 62 6f 75 6e 64 61 72 79 3d 37 35 34 62 63 34 36 35 2d 61 61 64 30 2d 34 31 64 34 2d 38 61 63 32 2d 32 66 33 33 33 65 63 32 63 30 31 31 0a 31 36 34 32 39 32 39 32 31 37 0a 2f 70 6c 6e 6d 73 2d 64 65 76 61 70 70 6d 65 64 69 61 2f 70 61 79 6d 65 6e 74 2d 72 65 63 65 69 70 74 2f 32 35 32 65 63 35 39 65 2d 30 39 34 37 2d 34 32 65 39 2d 39 64 31 31 2d 64 64 38 66 37 65 63 61 30 39 30 32 2e 6a 70 67</StringToSignBytes><RequestId>356AM1RVYQJRDBHM</RequestId><HostId>cMj3x6+X2Er0lSFHqDSaWCbKOXNw8qlNVqst7RIMllSyUr9bvkKn305dJRTqd31shmTmbLa972A=</HostId></Error>
我正在通过 PUT 方法进行分段上传。在邮递员上它正在工作但不是来自 Android
val requestFile: RequestBody = file.name.toRequestBody("image/jpeg".toMediaTypeOrNull())
val body: MultipartBody.Part = MultipartBody.Part.createFormData("image", file.name, requestFile)
val res= executeApiCall { octaveUserApi.uploadFile(uploadUrl,body)}
相关改造
@Multipart
@PUT
suspend fun uploadFile(
@Url url:String,
@Part filepart: MultipartBody.Part
): Response<String>
这是一个二进制文件上传,我是通过 multipart 上传的,但失败了
改造调用
@PUT
suspend fun uploadFile(
@Url url:String,
@Body filebody: RequestBody
): Response<RequestBody>
请求正文将是
Api.uploadFile(uploadUrl,file.asRequestBody("image/jpeg".toMediaTypeOrNull()))
当我调用 API 时,我得到一个 AWS S3 存储桶 URL 在 s3 URL 我正在尝试通过改造上传文件 但是我收到以下错误
<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message><AWSAccessKeyId>AKIA6F7T6E47MWT7QUOT</AWSAccessKeyId><StringToSign>PUT
multipart/form-data; boundary=754bc465-aad0-41d4-8ac2-2f333ec2c011
1642929217
/plnms-devappmedia/payment-receipt/252ec59e-0947-42e9-9d11-dd8f7eca0902.jpg</StringToSign><SignatureProvided>mcUVkLkJCtrlG5E0X+9uG3Yh5QA=</SignatureProvided><StringToSignBytes>50 55 54 0a 0a 6d 75 6c 74 69 70 61 72 74 2f 66 6f 72 6d 2d 64 61 74 61 3b 20 62 6f 75 6e 64 61 72 79 3d 37 35 34 62 63 34 36 35 2d 61 61 64 30 2d 34 31 64 34 2d 38 61 63 32 2d 32 66 33 33 33 65 63 32 63 30 31 31 0a 31 36 34 32 39 32 39 32 31 37 0a 2f 70 6c 6e 6d 73 2d 64 65 76 61 70 70 6d 65 64 69 61 2f 70 61 79 6d 65 6e 74 2d 72 65 63 65 69 70 74 2f 32 35 32 65 63 35 39 65 2d 30 39 34 37 2d 34 32 65 39 2d 39 64 31 31 2d 64 64 38 66 37 65 63 61 30 39 30 32 2e 6a 70 67</StringToSignBytes><RequestId>356AM1RVYQJRDBHM</RequestId><HostId>cMj3x6+X2Er0lSFHqDSaWCbKOXNw8qlNVqst7RIMllSyUr9bvkKn305dJRTqd31shmTmbLa972A=</HostId></Error>
我正在通过 PUT 方法进行分段上传。在邮递员上它正在工作但不是来自 Android
val requestFile: RequestBody = file.name.toRequestBody("image/jpeg".toMediaTypeOrNull())
val body: MultipartBody.Part = MultipartBody.Part.createFormData("image", file.name, requestFile)
val res= executeApiCall { octaveUserApi.uploadFile(uploadUrl,body)}
相关改造
@Multipart
@PUT
suspend fun uploadFile(
@Url url:String,
@Part filepart: MultipartBody.Part
): Response<String>
这是一个二进制文件上传,我是通过 multipart 上传的,但失败了
改造调用
@PUT
suspend fun uploadFile(
@Url url:String,
@Body filebody: RequestBody
): Response<RequestBody>
请求正文将是
Api.uploadFile(uploadUrl,file.asRequestBody("image/jpeg".toMediaTypeOrNull()))