What I’m trying to do:
I’m trying to upload an mp3 file from my Anvil app into my data table and an S3 bucket.
The uploader is working correctly.
The mp3 is making it to my data table correctly.
The issue is when I try to send to S3. I’m getting the below error, and I’m not understanding why it’s telling me that there is no such file. It was uploaded successfully to the data table a few seconds before.
anvil.tables.TableError: Column ‘audio’ can only be searched with a media (not a string) in table ‘uploads’
What I’ve tried and what’s not working:
I’m uploading the file from my desktop, using the file uploader.
Code Sample:
@anvil.server.callable
#The background server function that allows me to get around the 30 second server timeout issue
def upload_file(file):
with anvil.media.TempFile(file) as file_name:
if file.content_type == 'audio/mpeg':
app_tables.uploads.add_row(audio=file) #Line of code to send the MP3 file to the data table.
upload_to_s3(file)
else:
print("error")
pass
**#Upload the mp3 file to the S3 bucket
def upload_to_s3(file):
s3_client = boto3.resource('s3')
s3_client.meta.client.upload_file(app_tables.uploads.search(audio='wspy newscast.mp3'), 'wspyradio', file)
Clone link:
share a copy of your app