Environment Setup
ruby version: 2.7.0
rails version: 6.0.3.6
@rails/activestorage version: "^6.0.0"
Background
We are uploading all the files from our application to azure blob store using active storage direct upload method. It is working perfectly fine for file uploads smaller than 300 MBs. When I try to upload files greater than that I am getting this error
413 (The request body is too large and exceeds the maximum permissible limit.)
Here is how the request and response header looks like
Request Headers
PUT /development/xxxxxxxxxxxxx?sp=rw&sv=2016-05-31&se=2023-10-
23T10%3A48%3A35Z&sr=b&sig=FN%2BO03fVHeH5kvIB6H3O%2F6mD8410e9RBnNRDW54l0WY%3D HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9,ur;q=0.8
Connection: keep-alive
Content-Length: 422997346
Content-MD5: xxxxxxxxxx
Content-Type: application/octet-stream
DNT: 1
Host: xxxxxxx.blob.core.windows.net
Origin: http://localhost:5000
Referer: http://localhost:5000/
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/118.0.0.0 Safari/537.36
sec-ch-ua: "Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
x-ms-blob-type: BlockBlob
Response Headers
HTTP/1.1 413 The request body is too large and exceeds the maximum permissible limit.
Content-Length: 290
Content-Type: application/xml
Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-request-id: xxxxx-xxxx-xxxx-zzzx-xxxxxxxxx
x-ms-version: 2016-05-31
Access-Control-Expose-Headers: x-ms-request-id,Server,x-ms-version,Content-Length,Date,Transfer-Encoding
Access-Control-Allow-Origin: *
I have read that the solution to this problem is to chunk the file into smaller bits and then when upload is completed combine the smaller bits to make the file again. I have gone through online content indicating but the problem is I think activestorage.js should automatically be doing that. If it is not what is the possible solution here?