When doing a resumable upload to a file that was shared the url returned from createUploadSession can not be used.
Uploading directly with /content works but has a limit of 4MB
Scenario UserA
shares a file with edit permissions to UserB
Using the ms graph javascript sdk
const { uploadUrl } = await this.client.api(`/drives/${driveId}/items/${id}/createUploadSession`).post({});
trying to use uploadUrl
results in a 404 {"error":{"code":"itemNotFound","message":"The resource could not be found."}}
Interestingly the uploadUrl
looks something like this
https://{tenant}-my.sharepoint.com/personal/{UserA}_{tenant}_com/_api/v2.0/drives/${driveId}/items/${id}/uploadSession?guid='5b85df9e-b524-4000-9883-8106a13e592f'...
Not sure if its related to UserA being embedded in the url or not.
If UserA
accesses the same file and does a similar upload everything works fine on the file.
All of the following requests work fine for either User:
await this.client.api(`/drives/${driveId}/items/${id}/checkout`).post({});
await this.client.api(`/drives/${driveId}/items/${id}/content`).putStream(fs.createReadStream(filePath));
await this.client.api(`/drives/${driveId}/items/${id}/checkin`).post({});
uploadUrl
returned from createUploadSession should be valid for any user that had access to create an upload session.