Mar 22 2019 04:12 AM
Is there any API available to upload file in SharePoint? Sample code will be helpful.
If we upload same file using API will it replace the old file or create a new version of the file? Please advise.
Mar 22 2019 05:56 AM - edited Mar 22 2019 05:58 AM
Hey @Pulak2409 ,
I recommend you use PnPJs, since it makes handling REST calls a lot easier for you. This page shows how to work with files using it. A good point is that, after uploading the file, you may want to update it to set the Title of the Item you just created. Here is a piece of my code, which uploads from an input button. Any problem, let me know!
Mar 22 2019 07:38 AM
Solution@Pulak2409 Multiple APIs to do this.
REST API https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/working-with-folders-and-files-with-rest
You can also use CSOM using FileCreationInformation https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/upload-large-files-sample-app-for-...
You have the option to overwrite files in both scenarios
Mar 22 2019 07:38 AM
Solution@Pulak2409 Multiple APIs to do this.
REST API https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/working-with-folders-and-files-with-rest
You can also use CSOM using FileCreationInformation https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/upload-large-files-sample-app-for-...
You have the option to overwrite files in both scenarios