Hi,
I’m trying to implement uploading of files to Google Cloud Storage via the workers.
I built the whole process but I’m now stuck on one last thing.
Background:
We have a web app that you can upload any type of file with it to our servers.
We decided to switch from a VM server to using the GCS platform. All the requests are routed through Cloudflare, Therefore I created a route for the worker to process these requests.
I built the whole process for obtaining an access token for GCS and it uploads and creates the file in the desired bucket but this file is corrupt.
The upload originally is done with a multipart/form-data body format and I can extract the FormData object from the formData() method of the incoming request.
Then I can get(‘file’) form the FormData object I get. I believe that the problem is that in Cloudflare workers I don’t have the File object that the formData object should return when I call formData.get(‘file’) instead it returns the data as a string. I tried to add the returned object directly as the GCS requests body but as I said the resulting file is corrupt.
How can I get around this?