1

Hi all im new to FastAPI and im looking for a way to save excel files that are hosted on some server.

What I have currently is something like this and I can use that in FastApi function but I don't think that this is the best way to handle this.

import shutil
import urllib.request
from contextlib import closing

with closing(urllib.request.urlopen('ftp://server/path/to/file')) as r:
    with open('file', 'wb') as f:
        shutil.copyfileobj(r, f)

What i want to do is to pass some URL that leads directly to excel file on a server into API endpoint and i want to save it/open it

rafaelHTML
  • 379
  • 1
  • 9
  • Please have a look at [this answer](https://stackoverflow.com/a/74239367/17865804) and [this answer](https://stackoverflow.com/questions/63048825/how-to-upload-file-using-fastapi/70657621#70657621) as well – Chris Apr 20 '23 at 12:11

0 Answers0