79287942

Date: 2024-12-17 12:54:55
Score: 0.5
Natty:
Report link

I'm simply using Django's SimpleUploadedFile to test

from django.core.files.uploadedfile import SimpleUploadedFile

file = SimpleUploadedFile("invoice.pdf", bytes.fromhex("25504446") + b"test1234")

self.client.post(url, data={"invoice_file": file})

The Hex determines, that the created file is a PDF (as stated here https://stackoverflow.com/a/6187004/14698152)

My API directly uses the UploadedFile so i don't know if it works with the Schema you provided

from ninja import UploadedFile

def my_endpoint(self, invoice_file: UploadedFile = File(None)):
    ...dosomething()...
Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: FabianClemenz