What I’m trying to do:
I am trying to pass a file(anvil.Blobmedia) into the anvil.media.TempFile() Context Manager. However I notice that when the code runs the anvil.media.TempFile() Context Manager prints the file extension that is passed into the Context Manager to the console.
for example if I pass a txt anvil.Blobmedia file into anvil.media.TempFile() then ‘txt’ is printed to the console and same if I pass a csv anvil.Blobmedia file into anvil.media.TempFile() then ‘csv’ is printed to the console.
Will appreciate any assistance in I can get on resolving this.
Thank you very much.
Code Sample:
file = anvil.BlobMedia(
content_type='text/plain',
content=b'Hello, world!',
name='hello.txt'
)
with anvil.media.TempFile(file): # <-- prints the file extension that is passed into the TempFile class
pass
Clone link:
share a copy of your app
I have added server module _ with the code example, when you copy the app:
Run this in a server repel:
from .AnvilTempFileTest import test
test()
and you should expect this output → “txt”