john_helt
john_helt5mo ago

Hi! Is it possible to use a different

Hi! Is it possible to use a different backend for the mo.ui.file component? Instead of uploading to the server, I want to upload to a bucket somewhere. I'm thinking I could do this with the "on_change", but I don't know when that is applied (before or after the upload). Additionally, can I change the 100 mb limit?
3 Replies
Myles Scolnick
Myles Scolnick5mo ago
hey! yea we can make the limit configurable. but if you are deploying this on another cloud service, you make hit there limit e.g. cloud run's is 32 MiB 1. if that is not an issue, can you file a ticket to make the file-upload UI element take a configurable limit 2. i think having a different BE seems like a good idea. you probably don't want to make your bucket public. but a common use case (and a way to get around the limit on cloud providers) is providing a pre-signed url to upload. we could do something like mo.ui.file(get_presigned_url=handle_get_presigned_url) where:
def handle_get_presigned_url(filename, filetype):
# logic to return url (e.g. aws sdk, boto)
return url
def handle_get_presigned_url(filename, filetype):
# logic to return url (e.g. aws sdk, boto)
return url
and then we can upload it there. would need to scope out how that changes selection and the file logic https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-presigned-urls.html
john_helt
john_heltOP5mo ago
Hi! And sorry for not replying earlier with a thanks for your very detailed reply. I was on a long weekend, so I didn't check my messages until today. I actually played around with the mo.ui.file feature, and it seems the files are uploaded to the server memory, so they exists as python objects as a Bytes type, rather than actual files. So maybe the limit of 100 mb is related to memory, rather than disc-space? Regarding the backend, I am using AWS, and I create a client to upload files. The client is configured using environment variables, so I'm thinking it would be safe enough not to expose the endpoint to the app users.
Myles Scolnick
Myles Scolnick5mo ago
Yea I don’t think memory will be your first issue. Likely the request limit size that some platforms have. If you go the signed-url route, you won’t need to expose your AWS secrets.