We are not able to upload files >4MB below is the sample code. Please help.
UPLOADINg FILE of 7 MB to Azure File Share
UPLOADINg FILE of 7 MB to Azure File Share
Operation system : Linux
Client browser : Chrome
Azure Storage Type : File Share
Generation of SAS URL and creating empty file in file : Java
Uploading file using the SAS generated URL : Javascript
Sample Code
Backend code
//set policy
SharedAccessAccountPolicy policy = new SharedAccessAccountPolicy();
policy.setPermissions(EnumSet.of(SharedAccessAccountPermissions.READ, SharedAccessAccountPermissions.WRITE, SharedAccessAccountPermissions.LIST,
SharedAccessAccountPermissions.DELETE, SharedAccessAccountPermissions.CREATE));
policy.setServices(EnumSet.of(SharedAccessAccountService.FILE));
policy.setResourceTypes(EnumSet.of(SharedAccessAccountResourceType.OBJECT,SharedAccessAccountResourceType.SERVICE));
//policy.setSharedAccessExpiryTime(Date.from(ZonedDateTime.now(ZoneOffset.UTC).plusHours(24L).toInstant()));
policy.setSharedAccessExpiryTime(expiration);
policy.setProtocols(SharedAccessProtocols.HTTPS_ONLY);
//generate URL
String URL = endpoint+"/"+rootfoldername+"/"+storageDocumentPath+"?comp=range&"+azureaccount.generateSharedAccessSignature(policy)+"&sizeg="+fileSize;
//create a file
CloudFileDirectory dir = fetchRootDir("rootfoldername").getDirectoryReference(folderPath);
CloudFile file = dir.getFileReference(fileName);
file.create(fileSize);
front end code
while using the generated url from above to upload doing the header changes as below
options.headers['x-ms-write'] = "update";
options.headers['Range'] = "bytes=0-"+(file.size-1);
options.headers['x-ms-content-length'] = file.size;
we have tried with options.headers['x-ms-write'] = "clear";
But browser content-length can not make it zero
also but it does not work
Request Details Request URL: Request URL:
Request Details
Request URL: Request URL: https://<MYSHARENAME>.file.core.windows.net///?comp=range&ss=f&sig= SIGNATURE>&se=2021-03-09T16%3A39%3A15Z&sv=2015-07-08&srt=so&spr=https&sp=rcwdl&sr=so&sizeg=7905348
Request Method: PUT
Status Code: 413 The request body is too large and exceeds the maximum permissible limit.
Remote Address: <REMOTE ADDRESS>
Referrer Policy: strict-origin-when-cross-origin
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: x-ms-request-id,Server,x-ms-version,Content-Length,Date,Transfer-Encoding
Content-Length: 288
Content-Type: application/xml
Date: Tue, 09 Mar 2021 06:38:43 GMT
Server: Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0
x-ms-request-id: b34481d2-401a-0053-2bae-143300000000
x-ms-version: 2015-07-08
Accept: application/xml, text/xml, /; q=0.01
Accept-Encoding: identity
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Content-Disposition: attachment; filename="test.log"
Content-Length: 7905348
Content-Type: application/octet-stream
Host: <MYFILESAHRE>.file.core.windows.net
Origin: <MYDOMAIN>
Range: bytes=0-7905347
Referer: <MYDOMAIN>
sec-ch-ua: "Chromium";v="88", "Google Chrome";v="88", ";Not A Brand";v="99"
sec-ch-ua-mobile: ?0
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: cross-site
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36
x-ms-content-length: 7905348
x-ms-write: update