The Content-Range header length does not match the provided number of bytes when uploading chunks to OneDrive #638
Replies: 6 comments 6 replies
-
Hey @thewebartisan7 This error is strange, I cant tell why you'd specifically get it. Which Uploady version are you using? A couple of things: The first thing that immediately jumps at me is your configuration of (just saw the example in that page incorrectly used "grouped" config, so i removed it now) Another issue that might be important in the context of chunked uploads, is that typically you're required to supply a header with a unique value to help the server distinguish between chunks. You can use the useRequestPreSend hook for that if its needed. These issues shouldn't result in the error you're getting. If you can, please provide a reproducing sandbox and I'll take a look. |
Beta Was this translation helpful? Give feedback.
-
Hi @yoavniran thanks for your reply. Yes I saw it and I also tried without group and the actual code is: import ChunkedUploady, { useRequestPreSend } from '@rpldy/chunked-uploady';
import UploadButton from '@rpldy/upload-button';
type OneDriveUploaderProps = {
saveUrl: string;
accessToken: string;
};
const UploadButtonWithUniqueIdHeader = () => {
useRequestPreSend(async () => {
return {
options: {
destination: {
headers: {
'X-Unique-Upload-Id': `example-unique-${Date.now()}`,
},
},
},
};
});
return <UploadButton />;
};
const OneDriveUploader = ({ accessToken, saveUrl }: OneDriveUploaderProps) => {
return (
<ChunkedUploady
debug
destination={{
url: saveUrl,
headers: {
Authorization: `Bearer ${accessToken}`,
//'Content-Type': 'text/plain'
},
}}
chunkSize={5120000}
chunked={true}
//multiple
method='PUT'
>
<UploadButtonWithUniqueIdHeader />
</ChunkedUploady>
);
}; I tried to create a reproducing repo with vite and now I am getting another error, coming from OneDrive.. much better than before )) The error said:
Since the code require an access token to upload on OneDrive, I have upload everything in a private repo and I can give you access to it, where you can find also a working accessToken and temporary upload URL. Both should be valid around 1 hour, so in case this expire before, let me know and I can generate and update a new one. Let me know if you want to check or if you already can catch the problem with above code. The previous error was with webpack, coming from bluebird.js which seem being used by webpack or something else, because is not in any of my dependencies, so I am not sure from where is coming. |
Beta Was this translation helpful? Give feedback.
-
This is the screenshot of error that happen on main project with webpack: But considering that this doesn't happen with vite, the problem seem to be somewhere else. |
Beta Was this translation helpful? Give feedback.
-
hey @thewebartisan7 As for the promise error, again strange but its been a very long time since I saw someone use bluebird, thats the Promise polyfill, right? |
Beta Was this translation helpful? Give feedback.
-
Yes right.. I found that is being used by an old version of Ajv package that we are using. |
Beta Was this translation helpful? Give feedback.
-
Check here the gist https://gist.github.com/thewebartisan7/aa632ddf69f64c26f8abc5d90db50e1c However, I think that is exactly as you said. When sending with FormData it add additional content and such is increasing the length. While in my case I am just sending the File or Blob directly in the body of fetch. |
Beta Was this translation helpful? Give feedback.
-
UPDATE: The original issue that happen with bluebird (http://bluebirdjs.com/docs/error-explanations.html#error-the-promise-constructor-cannot-be-invoked-directly) doesn't happen with Vite, so I suppose is something unrelated with Uploady.
So the title has been updated with another issue that occur when uploading to OneDrive.
With below setup for chunked upload with OneDrive, I am getting below error:Unhandled rejection TypeError: the promise constructor cannot be invoked directlyThe HTTP request is not even sent.Beta Was this translation helpful? Give feedback.
All reactions