I have a website www.theraplounge.co that allows users to upload videos. The problem is our limit on file sizes are to small. How can I increase the file size users are able to upload through my forms.py FileField? By the way I’m currently using Amazon S3.
The problem here is heroku 30 second timeout as i found large files upload on development server but not the production server. The solution would be to upload the files in the front-end using javascript as it doesn't load the browser. I am currently trying to use Javascript AWS SDK to upload video files in the front-end. I got the code to work on small files under 30MB but i face the problem of uploading large files. Posting the working Javascript AWS SDK code below:
<div>
<input type="file" id="fileUpload">
</div>
<div>
<button onclick="s3upload()">Submit</button>
</div>
<script type="text/javascript">
function s3upload() {
AWS.config.region = 'us-east-1'; // Region
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'MY-COGNITO-CREDITIONS',
});
var files = document.getElementById('fileUpload').files;
if (files)
{
var file = files[0];
var fileName = file.name;
var fileUrl = 'https://theraplounge.s3.amazonaws.com/' + fileName;
var s3 = new AWS.S3({apiVersion: '2006-03-01'});
var params = {
Bucket: 'MY-BUCKET-NAME',
Key: fileName,
Body: file,
};
var s3 = new AWS.S3({apiVersion: '2006-03-01'});
var options = {partSize: 5 * 1024 * 1024, queueSize: 1};
s3.upload(params, options, function(err, data) {
if(err) {
alert('error');
} else{
alert('uploaded suceessfully')
};
});
console.log(s3)
}
};
</script>
This is the right approach as it doesn't load the browser at all but i cant get it to upload large files. Once I do find working Javascript code to upload large files I'll update this answer.
Edit: My problem with uploading large files was my cors policy at Amazon AWS. But also when launched to production I found that Javascript AWS SDK does load the browser and bypass heroku 30 timeout. So I added some knowledge to the process and created a two step form upload process that pass the videos s3 url to another view which would reset the 30s timeout and upload the other information. Test it out on my site www.theraplounge.co/ I manually set the max file size to 500MB but I could be more.