SignatureDoesNotMatch PUT/POST Google Buckets

I am trying to to a PUT request to a google bucket. I have the following ruby code as reference:

file = File.binread("spec/fixtures/files/truck.jpg")
upload = {
  filename: "truck.jpg",
  byte_size: file.size,
  checksum: Digest::MD5.base64digest(file),
  content_type: "image/jpeg",

response ="#{HOST}/api/uploads", headers:, json: { upload: })

if response.status.success?
  upload = JSON.parse(response.body)

  signed_id = upload["signed_id"]

  upload_url = upload["direct_upload"]["url"]
  upload_headers = upload["direct_upload"]["headers"]

  response = client.put(upload_url, headers: upload_headers, body: file)

I have managed to implement the first request already. It is the second part inside of the if that is giving me a headache. I am getting a SIgnatureDoesNotMatch error back, although they do match. I have annotated my code and added examples in the following image. On the bottom right you can see that the signatures seem to match, so I do not understand what I am doing wrong. Can anyone help? I have tried:

  • Sending PUT as demonstrated in the sample
  • Sending POST instead of PUT
  • Sending only the raw text

but to no luck. The file does exist on disk and is in the app scope, so permissions are not needed. It seems to read fine.

use the PutFIle block together with the correct url and request headers
do you have a link to the API documentation?
are there other examples codes available, probably php or JavaScxript or Android?


Hello Taifun, thank you for your answer. Sadly, theres no other examples available. There is a documentation however it is extremely useless, so I just kind of moved along with the example. Not sure what you mean with “Android” code, Python is below.

I have replicated the example in Python, a language I am more comfortable in compared to Ruby. I uploaded the code here. It seems to work fine, at least it is not returning an error. Therefore I am very sure the error has something to do with the MD5 digest. It may also be that I am reading my file as a string when a bytes object would be necessary.
What I noted in my python code was that this was very important:

md = hashlib.md5(file).digest()
contents_md5 = base64.b64encode(md).decode('utf-8')

It would not work without encoding it as base64 (for obvious reasons), so I tried adding this modification to just make sure I did not miss anything there:

However that does not seem to help either. Do you maybe have any ideas? If I can’t fix it I will try to contact the API operator, maybe he knows more.

You might want to post a screenshot of your latest blocks using the PutFile method including Do it results of the url and request headers


I have tried to make a sort of relay using PHP and have encountered the same exact issue. I have contacted the API operator in order to double check with him that I am doing everything right. Theres no docs from Google either. Still don’t understand why people make APIs that complicated, I’ve been having this block my development since Wednesday.
Thank you a ton for your answers, I will get back to this thread once I know more.