Questions tagged [django-file-upload]

Django-file-upload refers to how django handles file uploads

Django-file-upload refers to how django handles file uploads.

See documentation.

325 questions
4
votes
1 answer

Django and SuspiciousFileOperation:Detected path traversal attempt

I find myself in an odd situation only when deployed (debug == false): My model throws a path traversal attempt exception. I want to create a directory for every file uploaded and save the file within the directory (some.zip) used in example. In my…
xtlc
  • 1,070
  • 1
  • 15
  • 41
4
votes
1 answer

How can I get the temporary name of an UploadedFile in Django?

I'm doing some file validation and want to load an UploadedFile into an external library while it is in the '/tmp' directory before I save it somewhere that it can be executed. Django does the following: Django will write the uploaded file to a…
Matt Parrilla
  • 3,171
  • 6
  • 35
  • 54
4
votes
2 answers

Why won't my file save to instance (it saves to disk...)?

I can get my file to save to disk where I tell it to, but can't get it to save to the instance and I haven't the slightest idea why! models.py class Song(models.Model): name = models.CharField(max_length=50) audio_file =…
Matt Parrilla
  • 3,171
  • 6
  • 35
  • 54
4
votes
1 answer

File Upload using Django Rest Framework getting error "No file was submitted."

While trying to upload the file using Postman with Content-Type - multipart/form-data in the headers. I am passing both the fields, but I get the following error: Error:{"upload_to": ["This field is required."],"file_object": ["No file was…
SEJ
  • 296
  • 1
  • 16
4
votes
2 answers

Django - User uploaded S3 files in the view

I have a page where users can upload PDF / image files to their profile. The model for these files is relativly straightforward: class ResumeItemFile(models.Model): item = models.ForeignKey(ResumeItem, related_name='attachment_files') file =…
Jasper
  • 2,131
  • 6
  • 29
  • 61
4
votes
1 answer

Download from MEDIA_ROOT does not work

I'm trying to make one User to upload a file (in some language) and another User to download it so they can translate it. I've set media root adn media url: MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = '/media/' When someone uploads a…
Milano
  • 18,048
  • 37
  • 153
  • 353
4
votes
0 answers

How do I create a resumable file upload using django rest framework

The question is stated above. While there are many tutorials about file upload using django rest framework. None mentioned about the resumable version of it. And I need to implement it for a project. Can someone point me to some resources or give a…
Mox
  • 2,355
  • 2
  • 26
  • 42
4
votes
2 answers

Trying to use django and dropzone/

I'm trying to use dropzone.js with django. I'm following the somewhat dated guide here (https://amatellanes.wordpress.com/2013/11/05/dropzonejs-django-how-to-build-a-file-upload-form/) I strongly suspect My view is at issue. def test(request): …
4
votes
1 answer

Sending file through POST, Django/python request obj not storing correctly

I'm using a simple REST client to test. Sending a simple JPEG, tried the following content-Type(s): Content-Type: image/jpeg Content-Type: multipart/form-data Also note csrftoken authentication is turned off to allow outside 3rd party REST…
Darthyogurt
  • 127
  • 2
  • 11
4
votes
2 answers

Django - How to update a field inside a model save() method?

It is possible to update a model field inside the save() method? models.py: class BicycleAdItemKind(MPTTModel): image_file_temp_fullpath = "" image_file_temp_filename = "" def url(self, filename): #pdb.set_trace() #url…
André
  • 24,706
  • 43
  • 121
  • 178
3
votes
1 answer

How to sync the upload progress bar with upload on s3 bucket using Django Rest Framework

I am working on a REST API (using Django Rest Framework). I am trying to upload a video by sending a post request to the endpoint I made. Issue The video does upload to the s3 bucket, but the upload progress shows 100% within a couple of seconds…
3
votes
1 answer

Manually pass files to Django Form

I have a form: class MessageAttachmentForm(forms.ModelForm): class Meta: model = MessageAttachment fields = ("attachment",) And in my view, I have it receive some files with the incorrect names so I try to create a new…
3
votes
2 answers

How to get the fieldname of a FileField in the upload_to method, for a field translated with modeltranslation in Django?

I am using django modeltranslation on a FileField. I would like this file to be uploaded in a path /path/to/file//file.ext and I guess the best way is to extract the lang from the fieldname (file_en, file_it, file_fr, ...) where upload_to is…
3
votes
1 answer

How to upload multiple files from the Django admin?

I want to upload multiple files in the Django admin, without having to place multiple FileField fields. The user can be able to manage the files in a simple way; delete or change each uploaded file but upload several at once. the solution I see…
3
votes
1 answer

Django: FileField, missing content_type

If I read the docs correctly, then the FileField in Django does not know the content_type of the file: https://docs.djangoproject.com/en/2.1/ref/models/fields/ I would like to store files in a Django application, but I want to query the…
guettli
  • 25,042
  • 81
  • 346
  • 663
1 2
3
21 22