When not seeing quickly somethign obvious I prefer to give a closer look at what happens before reading the code again. For example here I would likely use test data with a know pattern (for example byte 0 to 255 and repeat or a single byte value for each
chunk) so that I can easily understand how the final file differs. I like also to always have a fallback for example here if I don't get one the two reponse code you seems to expect.
Edit: never tried this particular area but I often favor using
https://www.nuget.org/packages/Microsoft.Graph over crafting my own queries (not sure if and how this particular API is exposed).
Member
23 Points
157 Posts
Microsoft graph api onedrive file gets corrupted when uploading file
Oct 14, 2020 05:45 AM|slkim|LINK
.net core API Code
This is the code to upload using the OneDrive api.
The file was not damaged when the file was previously uploaded, but if it was recently uploaded, it is uploaded as a damaged file.
Can you see why?
The URL is an upload session, and files are uploaded through the upload session.
Looking at the hash code of the file, the file is altered and uploaded.
(The hash value is modulated.)
All-Star
48570 Points
18082 Posts
Re: Microsoft graph api onedrive file gets corrupted when uploading file
Oct 15, 2020 09:44 AM|PatriceSc|LINK
Hi,
This is based on https://docs.microsoft.com/en-us/graph/api/driveitem-createuploadsession?view=graph-rest-1.0?
When not seeing quickly somethign obvious I prefer to give a closer look at what happens before reading the code again. For example here I would likely use test data with a know pattern (for example byte 0 to 255 and repeat or a single byte value for each chunk) so that I can easily understand how the final file differs. I like also to always have a fallback for example here if I don't get one the two reponse code you seems to expect.
Edit: never tried this particular area but I often favor using https://www.nuget.org/packages/Microsoft.Graph over crafting my own queries (not sure if and how this particular API is exposed).
Member
23 Points
157 Posts
Re: Microsoft graph api onedrive file gets corrupted when uploading file
Oct 15, 2020 10:58 AM|slkim|LINK
I constructed the code by referring to the tutorial you gave me
When comparing the original file and the file uploaded to One Drive through api, the uploaded file was damaged.
The hash values of the original file and damaged file did not match.
(File information was checked through PowerShell)
Can I check out the upload tutorial for OneDrive SDK?
We would appreciate it if you let us know a site that you can refer to.
thank you