I am trying to upload a file to Google Cloud Storage using the signed url generated by the backend server it gives this error
SignatureDoesNotMatch
The request signature we calculated does not match the signature you provided. Check your Google secret key and signing method.PUT
multipart/form-data; boundary=50b17d2b-3095-4762-b93f-fa87bbe1c7bd
1926666331
/bucket_name/r1m767lcbtxnuu34hu9klrljf65q</StringToSign></Error>
i am using okhttp put request with multipart to upload the file like this
private fun directUpload(signedUrl: String, file: File) {
try {
val requestBody: RequestBody = RequestBody.create(
file.getMimeType().toMediaTypeOrNull(),
file
)
val request: Request = Request.Builder().url(signedUrl).put(requestBody)
.build()
val client = OkHttpClient()
val response: Response = client.newCall(request).execute()
if (response.isSuccessful) {
response.toString()
Log.d("Response_Direct_Upload", "FileUploaded")
} else {
Log.d("Response_Direct_Upload", response.body?.string().toString())
}
} catch (ex: Exception) {
Log.d("Response_Direct_Upload", "FileUploadFailedException")
}
}
The signed url generated by server looks like this