Hi all! I’m trying to set up a connection to a SharePoint site where users can browse/read files and upload new documents.
I’ve used the SharePoint use case sample in Showroom and have the “navigate site / read files” parts working. But I haven’t been able to replicate a working workflow for file upload.
From what I can tell after reading the docs, the Microsoft Graph upload endpoints expect raw binary content, while Appfarm’s Raw type seems to send a raw text payload.
Has anyone successfully implemented SharePoint file uploads via Graph from Appfarm? If so, I’d appreciate any pointers on the correct approach (endpoint choice, encoding, request setup, etc.).
An example of this is found in the Showroom as well, in the action Sharepoint - Large file upload (MAIN) under the application Use Cases.
For a file that is bigger than 4MiB, the file needs to be sliced into smaller chunks which are sent to the same upload URL. You can generate an upload URL through the endpoint https://graph.microsoft.com/v1.0/sites/${siteId}/drive/items/${parentItemId}:/${documentOriginalFileName}:/createUploadSession`
Once an upload URL is generated, the file object itself needs to be sliced into chunks so that the endpoint can handle the size. You can create a file object with source type Custom, and the custom file content should be: sharepointFileObject.__file.slice(startByte, endByteSlice)
To upload the newly created file slice to Sharepoint - The web request is with method PUT, and sent towards the provided upload URL from Sharepoint. The same upload URL should be used for each chunk of the same file. The body type is set to Raw, and then the content type should be set to Custom. Body Content can then directly be data bound to the File Data of the correct File Object. Content-Range should be added as a Request Header when setting the content type to Custom. The Content-Range header should be in the format: `bytes ${startByteHeader}-${endByteHeader}/${fileSize}`
where startByteHeader and endByteHeader describe the start and end location of the chunk in the context of the overall file size.
If there is anything unclear from the Showroom setup or from the description over, then let me know and I can try and assist further.