Uploading File Error: Content Size mismatch

I am attempting to set up an integration with a DAM to upload photos to google drive.

I translate their instructions (can find them here) to query triggers but it is still not working.

In particular, I keep receiving a 400 error with the following message: "There were 31689 byte(s) (or more) in the request body. There should have been 23755 byte(s) according to the Content-Range header" . I can confirm that the size attribute for the file shows as 23755. I have no idea where the additional bytes might be coming from.

Here is my script so far:

Here is current GDsendFileQuery:

I originally included headers with MIMEtype and content length but I still received the same error. Given that the error occurs regardless of how I send the data (json, raw, binary) I'm wondering if there's an issue with the metadata of the image itself? Can't figure out where my error is.

Hey @rgm!

I'm curious to see what GDsendFileQuery.metadata populates with, would you mind checking that and posting it here?

The only thing that jumps out to me at first glance here is that there's no await on GDUploadUrlQuery.trigger. You might want to have getGDUploadUrl be an async function, make sure this setting is turned on for the JS query you're running, and then await both GDUploadUrlQuery.trigger and getGDUploadUrl in your script.

Let me know if that helps, otherwise, it might help to see more information about the actual request that's being sent and double-check that against what you're expecting.

Hi Kabirdas,

Thanks for your help! Unfortunately checking "Keep variable references ...in sync" and awaiting GDUploadURLQuery.trigger and getDGUploadUrl does not seem to resolve the problem. The thing that is throwing me is that google appears to be saying that I am sending more bytes than expected. I am unsure how that would be possible.

Metadata for GDsendfileQuery appears to be null:

Here is the state of the fileInput component with a test image:


As you can see, the size is 153053, which is being correctly detected in the error. However, the response I get from GDSendFileQuery says I am actually sending 204072 bytes.

Here is the error specific to uploading this test file:

"{"message":"Invalid request. There were 204072 byte(s) (or more) in the request body. There should have been 153053 byte(s) according to the Content-Range header."}","data":{"message":"Invalid request. There were 204072 byte(s) (or more) in the request body. There should have been 153053 byte(s) according to the Content-Range header."},

And here is the metadata from the error object:


The body should be the base64 encoded file being uploaded.

Is there any other information that I can provide that would be more helpful? Really appreciate your help on this.

Hey @rgm,

Sorry for the late reply, I'm not sure what's going on here but will continue to investigate and get back to you. In the meantime, does using fileInput1.value[0].length instead work?

Hi @Kabirdas,

Specifying size as fileInput1.value[0].length does seem to solve the error! Any ideas why the length would be different than the size as per the file_upload component?

It looks like fileInput1.files[0].size refers to the size of the file in bytes whereas fileInput1.value[0].length gives the length of the base64 encoded string. More info on each here!

Each Base64 digit represents exactly 6 bits of data. So, three 8-bits bytes of the input string/binary file (3×8 bits = 24 bits) can be represented by four 6-bit Base64 digits (4×6 = 24 bits).

This means that the Base64 version of a string or file will be at least 133% the size of its source (a ~33% increase).

You might notice that 153053 * 4 / 3 = 204071

Got it! Thank you for all your help on this.