我正在使用已签名的请求尝试使用volley将文件上传到Android中的AWS S3。
我尝试实现this code,但我有一个错误403:
<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>xxx</AWSAccessKeyId>
<StringToSign>PUT
x-www-form-urlencoded; charset=UTF-8 <!-- Not wanted parameters -->
expireTimeStamp
/my-url
</StringToSign>
<SignatureProvided>xxx</SignatureProvided>
<StringToSignBytes>xxx</StringToSignBytes>
<RequestId>xxx</RequestId>
<HostId>xxx</HostId>
</Error>
那么,如何从截击请求中删除x-www-form-urlencoded; charset=UTF-8
?
答案 0 :(得分:0)
简单地说:
@Override
public String getBodyContentType()
{
return "";
}
答案 1 :(得分:0)
确保标题:
和 身体
public static byte[] getBytes(Context context, Uri uri) {
InputStream iStream = null;
try {
iStream = context.getContentResolver().openInputStream(uri);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
byte[] inputData = new byte[0];
try {
ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();
int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];
int len;
while ((len = iStream != null ? iStream.read(buffer) : 0) != -1) {
byteBuffer.write(buffer, 0, len);
}
inputData = byteBuffer.toByteArray();
} catch (IOException e) {
e.printStackTrace();
}
return inputData;
}
@Override
public String getBodyContentType() {
return null;
}