I have made a connection with Google Storage using gem 'google-cloud-storage'. Repo for that is https://github.com/GoogleCloudPlatform/google-cloud-ruby/tree/master/google-cloud-storage.
The example of the signed_url method I couldn't manage to find it only in one example in the repo, here, line 916: https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/google-cloud-storage/lib/google/cloud/storage/bucket.rb
I managed to get a signed URL for method GET for a specific file, but when I try to do a PUT on the signed_url for a file it gives me a response body like so:
<Error>
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your Google secret key and signing method.</Message>
<StringToSign>PUT
application/x-www-form-urlencoded
1523909074
/bucket_name/logo1</StringToSign>
</Error>
Sample code of PUT (NOT WORKING):
require 'google/cloud/storage'
storage = Google::Cloud::Storage.new(
project_id: 'projectId',
credentials: './config/keyfile.json'
)
bucket = storage.bucket 'bucket_name'
signed_url = bucket.signed_url 'logo1.png',
method: 'PUT',
content_type: 'image/png',
expires: 300 # 5 minutes from now
I tried doing with and without content_type. Also I tried content_type: '*' or '**' or 'image/*' or ''. I tried the PUT request in Postman and in an Angular app using a primeng upload component. Need a little help. Thanks.