I have deployed a FastAPI application in Digitalocen App Platform and I’m trying to upload, write, and modify a file. This is the code I’m using:
@router.post( "/", response_model=schemas.GeneralResponseObj, status_code=status.HTTP_201_CREATED ) async def load_file(file: UploadFile = File(...), source: str = ''): """ Load a file """ content = file.file.read() with open(file.filename, "wb") as f: f.write(content) # SOME CODE THAT READS THE FILE os.remove(file.filename) return schemas.GeneralResponseObj( message="Saved new data" )
It works locally but on the App Platform I receive:
with open(file.filename, "wb") as f: ******* PermissionError: [Errno 13] Permission denied
How can I fix this error? Any help is much appreciated. Thanks
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.