Hey folks!
What I’m trying to do:
- Sending an existing .mp4 file from my Google Colab to my anvil endpoint via curl
- Grab the get_bytes(), create a BlobMedia object and store it in a media table
- Download the video file from the media table directly (this fails)
What I’ve tried and what’s not working:
I tried many approaches, but what still does not work is: the file seems to be corrupt if I download it from the media table.
Code Sample:
# on Google Colab
@anvil.server.http_endpoint('/update_video')
def sendVideoData(**q):
returnValue = !curl -X POST -H "Content-Type: video/mp4" -F 'video=@video.mp4' https://YRTYBNHX5VIVWH3L.anvil.app/_/private_api/XYZ/updatevideo
print(returnValue)
return
# on Anvil (Server Module)
@anvil.server.http_endpoint('/updatevideo',
methods=["POST"], authenticate_users=False)
def update_video(**q):
multipart_bytes = anvil.server.request.body["data"].get_bytes()
videoBlobMedia = anvil.BlobMedia(content_type="video/mp4", content=multipart_bytes, name="video10.mp4")
app_tables.videos.add_row(Video=videoBlobMedia)
return anvil.server.HttpResponse(201)
Result: when I try to download the successfully saved file from the database, the .mp4 seems to be corrupt.
Any help is appreciated!