I am trying to upload a large file on sharepoint via rest api callout using JavaScript but not able to upload files having size more then 250MB.
Below mentioned is the logic that I have implemented -
<html>
<head>
<title>File Upload with Fetch API</title>
</head>
<body>
<form>
<input type="file" id="fileInput" name="fileInput">
<button type="button" id="uploadButton">Upload</button>
</form>
<script>
const uploadButton = document.getElementById('uploadButton');
const fileInput = document.getElementById('fileInput');
accesstoken='{ACCESS_TOKEN}';
filename ='Test1.pdf';
const endpoint = 'https://<Tenant Name>.sharepoint.com/sites/<SiteName>/_api/web/GetFolderByServerRelativeUrl(\'' + '/sites/<SiteName>/Shared%20Documents/<FolderName>' + '\')/Files/add(url=\'' + filename + '\',overwrite=true)';
uploadButton.addEventListener('click', () => {
const file = fileInput.files[0];
const formData = new FormData();
formData.append('file', file);
fetch(endpoint, {
method: 'POST',
headers: {
'Authorization': 'Bearer '+accesstoken,
'Content-Type': 'multipart/form-data',
'Accept': 'application/json; odata=nometadata',
'X-RequestDigest':'<FORM_Digest>'
},
body: formData
})
.then(response => response.json())
.then(data => {
alert('File uploaded successfully!');
})
.catch(error => {
alert('Error uploading file');
});
});
</script>
</body>
</html>
By this logic I am able to upload files on SharePoint but of size less than 250MB.
If I try to upload file greater than 250MB it throws error in response, which is below mentioned -

Please suggest some solution thanks in advance.