Not Able to Upload Files through api larger than 250 MB

Copper Contributor

We are uploading the files using this Microsoft API “("/{webUrl}/_api/web/lists(guid'{listId}')/items({itemId})/File/$value")” and we are getting error as “The request message is too big. The server does not allow messages larger than 262144000 bytes.” which says we can’t upload files more that 262 MB. Can you suggest an alternative API with which we can upload file more than 300MB size?

5 Replies

Hi @NeeradaSkyhigh,

you can chunk your upload into multiple parts that are smaller than 250 MB

 

/_api/web/getfilebyserverrelativeurl('/Path/to/file')/startupload(uploadId={a guid})

/_api/web/getfilebyserverrelativeurl('/Path/to/file')/continueupload(uploadId={your guid from above}, fileOffset={number of bytes uploaded in previous step})

/_api/web/getfilebyserverrelativeurl('/Path/to/file')/finishupload(uploadId={your guid from above}, fileOffset={total number of bytes uploaded in previous steps})

 


Here is an example using C# 
https://sharepoint.stackexchange.com/questions/161845/using-chunked-upload-startupload-with-sharepoi...

Best Regards,
Sven

@NeeradaSkyhigh If you are trying ti via SharePoint framework (SPFx), try using PnP JS library for file uploads.

 

Follow this documentation for large file uploads:

  1. @pnp/sp/files - Adding files 
  2. Working with large files 

Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

For SharePoint/Power Platform blogs, visit: Ganesh Sanap Blogs

Hi @SvenSieverding and @ganeshsanap  ,

 

We have two operations at the files, when we are detecting violated content we copy that file into the quarantine folder and another operation is if user wants to restore the file then we upload the file in the current location again with the help of upload file API from the quarantine folder.

1.The API which is used in copying the file to quarantine is (

@POST("/_api/SP.MoveCopyUtil.CopyFile")
@Headers({"Content-Type: application/json"})

) which is working fine for larger files.

2. The API for restoring the file we are using 


@PUT("/{webUrl}/_api/web/GetFileByServerRelativePath(decodedurl=@relativeUrl)/$value")

 This is getting failed with the above error message "Size is too big...." 

Since the approach you have mentioned is using 3 APIs to upload large files. Instead of that can we. use this copyFile API, if yes will this retain the versioning of files?

We are not using sharepoint framework.

@NeeradaSkyhigh Yes, you should be able to copy or move those files back to original folder by using API.

 

Check this documentation for reference to see all available API endpoints: MoveCopyUtil Class 

 

Not sure if it retains the versioning history. You can test it by trying to copy/move test files in development site.


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

For SharePoint/Power Platform blogs, visit: Ganesh Sanap Blogs