ref: https://cloud.google.com/nodejs/docs/reference/storage/1.5.x/File#getSignedPolicy
I am trying to upload files to my bucket using signed policies. Using the example from the documentation I get a response from my bucket object for 3 items.
"policyString": "{\"expiration\":\"2019-10-18\",\"conditions\":[[\"eq\",\"$key\",\"image.jpg\"],{\"bucket\":\"my-bucket\"},[\"eq\",\"$Content-Type\",\"image/jpeg\"],[\"content-length-range\",0,1024]]}",
"policyBase64": "[some-long-string]",
"policySignature": "[some-long-string]"
In the documentation it also shows you how to upload objects using curl.
ref: https://cloud.google.com/storage/docs/object-basics#upload-object-json
How do you assemble what I get back as a signed policy and the upload api
https://www.googleapis.com/upload/storage/v1/b/[BUCKET_NAME]/o?uploadType=media&name=[OBJECT_NAME]
to upload a file to my bucket using axios? Is there other headers to attach?
Here is what I did to take a stab at it but I'm not sure.
const options = {
headers: {
'Authorization': ?
'Content-Type': file.type
}
}
axios.put(concatenatedPolicySignatureUrl, file, options)
.then(response => {
console.log('success!');
}