I'm trying to create a GCS resumable upload url on the backend, send it to the frontend to get javascript to start a big file upload directly to the bucket.
My problem, currently, is that I can't figure out how to start the upload.
All the documentation doesn't have any code, so there is nothing for me to be based on.
My code, currently, is this:
def start_resumable_upload(self):
API_ENDPOINT = (
'https://www.googleapis.com/upload/storage/v1beta2/'
'b%(bucket)s/o?uploadType=resumable&name=%(object_name)s'
)
url_params = {
'bucket': BUCKET,
'object_name': self.filename
}
headers = {
'X-Upload-Content-Type': self.content_type,
'X-Upload-Content-Length': 0,
'Content-Type': 'application/json'
}
r = urlfetch.fetch(
url=API_ENDPOINT % url_params,
method=urlfetch.POST,
headers=headers
)
return r.content
start_resumable_upload is a method within the file Model I created to keep track of metadata on the database, thus, self.filename will have the filename, content_type will be the mime type and so on.
The response of that request is:
400. That’s an error.
Your client has issued a malformed or illegal request. That’s all we know.
which is somewhat unacceptable.
Any help is appreciated.