0

I have an app built in Django and currently deployed on Google App Engine. Everything works fine except for when I want to upload files larger than 32MB. I get an error which says, 413. That’s an error.

I have been doing some research and I've come to realize that I have to use Google App Engine's Blobstore API. I have no idea on how to implement that on my Django App.

Currently my code looks something like this:

Model:

class FileUploads(models.Model):
    title = models.CharField(max_length=200)
    file_upload = models.FileField(upload_to="uploaded_files/", blank=True, null=True)

Form:

class UploadFileForm(forms.ModelForm):

    class Meta:
        model = FileUploads
        fields = ["title", "file_upload"]

View:

def upload_file(request):

    if request.method == "POST":
        form = UploadFileForm(request.POST, request.FILES)
        if form.is_valid():
            form.save()  
    form = UploadFileForm()

    return render(request, "my_app/templates/template.html", {"form": form})

Everything works fine. I would just like to know how to implement Google App Engine's Blobstore API on my current code structure to enable large file uploads.

Makakole
  • 1
  • 1
  • 1

1 Answers1

0

From Google Cloud Official Documentation:

There exists limits that apply specifically to the use of the Blobstore API.

  • The maximum size of Blobstore data that can be read by the application with one API call is 32 megabytes.

  • The maximum number of files that can be uploaded in a single form POST is 500.

Your code looks fine, and this is an expected error due to Blobstore API quotas and limits. One way would be to split up your file sizes, which should not exceed 32 MB, and make multiple API calls when uploading larger files. Another solution would be to upload directly to Google Cloud Storage.

Hope this clarifies your question.

sllopis
  • 2,292
  • 1
  • 8
  • 13