File upload timeout

I’m trying to find out a way to upload large files and avoiding a timeout error (e.g 50MB+). I’ve seen that using a client writeable view may be a solution. Does anyone have an exmaple of this or a better way to do this?

Here’s some sample code from where I use that technique. It’s out of context, but should give you the general idea:

This is in the client form where the user is uploading a file. It’s a two step process, the first server call gets the client-writeable view, and the second allows the server to transfer the media from the temporary table to the right one.

    upload_table = anvil.server.call('author_prep_media')
    media_upload = upload_table.add_row(media=self.file_loader_1.file)
    result = anvil.server.call('author_add_media', media_upload, self.media_id.text, self.source.text, self.tags_edit.tokens)

Server functions:

I have a media_upload table that has a media column and a user column. It’s for temporary storage of the media during upload.

@anvil.server.callable
def author_prep_media():
  return app_tables.media_upload.client_writable(user=anvil.users.get_user())

This server function copies the media from the temporary table to the permanent table (media):

@anvil.server.callable
def author_add_media(media_upload, media_id):
  media_record = app_tables.media.add_row(media_id=media_id.lower(), uploaded_by=user)
  media_record['media'] = media_upload['media']
  media_upload.delete()

I’m sure there are lots of variations on this. The important bit is passing the client writeable view back to the form and then adding the row to that table in the client.

Original discussion of that technique is at: