Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot upload PDFs, mp3s, mp4s etc. using the Content Management API. Images work fine. #539

Closed
RyuLindow opened this issue Feb 7, 2022 · 2 comments

Comments

@RyuLindow
Copy link

Issue description

I get a 422 response when trying to upload a PDF
image

Here's the cURL:

curl --request POST \
  --url https://api.umbraco.io/media \
  --header 'Api-Key: myKey' \
  --header 'Content-Type: multipart/form-data; boundary=---011000010111000001101001' \
  --header 'umb-project-alias: projectAlias' \
  --form 'content={
	"mediaTypeAlias": "File",
	"name": "debug",
	"umbracoFile": "name.pdf"
}' \
  --form 'umbracoFile=@C:\Users\Darek\Desktop\name.pdf'

I've tested this on 2 projects and made a GET call to see what the PDF would return.
Migrated project returns:
"mediaTypeAlias": "File"
New project returns:
"mediaTypeAlias": "umbracoMediaArticle"

That is cause from what I can see none of the migrated projects received the additional media types such as article, audio etc.
Either way, uploading the PDF doesn't work whether I input File or umbracoMediaArticle in the call.

I've also confirmed that the extension .pdf isn't disallowed in the uploadFile field.

It is, however, possible to upload a PDF by using this format:

curl --request POST \
  --url https://api.umbraco.io/media \
  --header 'Api-Key: myKey' \
  --header 'Content-Type: multipart/form-data; boundary=---011000010111000001101001' \
  --header 'umb-project-alias: projectAlias' \
  --form 'content={
	"mediaTypeAlias": "Image",
	"name": "tis a pdf" ,
	"umbracoFile": { "src": "tis-a-pdf.pdf" },
	"umbracoExtension": "pdf"
}' \
  --form 'umbracoFile=@C:\Users\Darek\Desktop\tis-a-pdf.pdf'

The problem with this is that the PDF ends up like this:
image
image
image

Using any of the others media type aliases in the mediaTypeAlias results in the call creating a media container but not uploading the actual file into it like so:
image

@sitereactor sitereactor added state/in-sprint We've committed to work on this during the sprint indicated in the milestone state/needs-investigation This requires input from HQ or community to proceed labels Feb 8, 2022
@RyuLindow
Copy link
Author

Can verify that it works now after the patch today :)

@ICATT
Copy link

ICATT commented Feb 15, 2022

I can confirm it works for us, too. Thanks!

@umbrabot umbrabot removed state/in-sprint We've committed to work on this during the sprint indicated in the milestone state/needs-investigation This requires input from HQ or community to proceed labels Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants