ImageField validation doesn't allow me save a path #8898
Unanswered
mgaligniana
asked this question in
Question & Answer
Replies: 1 comment 3 replies
-
I think you could try https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Let's say I have this model to save an image:
with this serializer:
Then I moved to S3 using Presigned Urls: instead of upload a file, the frontend does it for me, and I just do a POST to the Profile's view with
photo
as the path which S3 gave me (i.e. uploads/photos/foo.png)I can run
profile = Profile.objects.create(photo="uploads/photos/foo.png")
successfully and then have access toprofile.url
(MEDIA_ROOT + path) andprofile.name
(foo.png).But when I want create it via POST I get "The submitted data was not a file. Check the encoding type on the form." because it requires send
size
:django-rest-framework/rest_framework/fields.py
Line 1513 in 15c613a
serializers.FileField
differ from themodels.FileField
validation logic?POST
to/api/v1/profiles/
with{"photo": "foo/bar/baz.png}"
and then retrieve the profile and get{"id": 1, "photo": "https://s3-bucket.com/foo/bar/baz.png}"
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions