file-upload

File upload using FastAPI returns error 422

File upload using FastAPI returns error 422 Question: I am using the example from the official documentation: https://fastapi.tiangolo.com/tutorial/request-files/#import-file Server code: @app.post("/uploadfile") async def create_upload_file(data: UploadFile = File(…)): print("> uploaded file:",data.filename) return {"filename": data.filename} Client code: files = {‘upload_file’: open(‘config.txt’, ‘rb’)} resp = requests.post( url = URL, files = files) print(resp.json()) The problem is that the …

Total answers: 2

How to use FileUpload widget in jupyter lab?

How to use FileUpload widget in jupyter lab? Question: I want to use the FileUpload widget in jupyter lab. I have the following lines of code in my notebook cell: uploader = widgets.FileUpload() uploader In jupyter notebook, the output of the cell is a clickable button that I can use to upload a file. In …

Total answers: 4

python AWS boto3 create presigned url for file upload

python AWS boto3 create presigned url for file upload Question: I’m writing a django backend for an application in which the client will upload a video file to s3. I want to use presigned urls, so the django server will sign a url and pass it back to the client, who will then upload their …

Total answers: 3

how to upload a file into the WIKI of GitLab using Python

how to upload a file into the WIKI of GitLab using Python Question: Using the Python module python-gitlab, project management can be done on a GitLab server without using the built-in GitLab WEB-GUI, directly. So, the git repository and wikis can programmatically be operated on. Now, I have found a way to download, edit and …

Total answers: 2

Copy file into another folder with django?

Copy file into another folder with django? Question: I need to upload profile images into diferent folders in Django. So, I have a folder for each account, and the profile image have to go to the specific folder. How can I do that? Here is my uploadprofile.html <form action=”{% url ‘uploadimage’ %}” enctype=”multipart/form-data” method=”POST”> {% …

Total answers: 3

How to generate download link

How to generate download link? Question: I’m triying to create a link to download file which has been uploaded. models.py class Comentario (models.Model): archivo = models.FileField(upload_to=’media’, null=True, blank=True) settings.py MEDIA_ROOT=os.path.join(BASE_DIR, ‘media’) MEDIA_URL=’/media/’ template.html <a href="{{ MEDIA_URL }} {{detail.archivo.url}}" download>Descargar</a> views.py def ComentarioListar(request): form2 = ComentarioForm(request.POST or None, request.FILES or None) if request.method == ‘POST’ and …

Total answers: 1

Simulate multipart/form-data file upload with Falcon's Testing module

Simulate multipart/form-data file upload with Falcon's Testing module Question: This simple Falcon API will take a HTTP POST with enctype=multipart/form-data and a file upload in the file parameter and print the file’s content on the console: # simple_api.py import cgi import falcon class SomeTestApi(object): def on_post(self, req, resp): upload = cgi.FieldStorage(fp=req.stream, environ=req.env) upload = upload[‘file’].file.read() …

Total answers: 2

Need an Example of Django big File upload with upload file handler method

Need an Example of Django big File upload with upload file handler method Question: In one of my django project I am trying to upload files. Files can be video files and can be big as 20 MB. I am trying to upload it with celery and upload_file_handler method given in django docs. What I …

Total answers: 1