Reputation: 33
I am using the Imgur API to upload images to albums, as part of a Reddit bot. However, when I try to upload MP4 files I get an error: "File type invalid (1)". Uploading the exact same MP4 file using the website works just fine.
I am using this endpoint to upload the file: POST https://api.imgur.com/3/image
https://apidocs.imgur.com/#c85c9dfc-7487-4de2-9ecd-66f727cf3139
Upvotes: 3
Views: 5626
Reputation: 2414
I agree with a comment above. Now it is works great. Even you can upload the video without authorization. Just using a POST method https://api.imgur.com/3/upload. Pass a video file in body with image
key. That's all.
Example in Postman
Upvotes: 1
Reputation: 540
The above comment is no longer correct -- You can indeed upload an MP4 using Imgur API
import requests
url = "https://api.imgur.com/3/upload"
payload = {'album': 'ALBUMID',
'type': 'file',
'disable_audio': '0'}
files = [
('video', open('/path/to/Video.mp4','rb'))
]
headers = {
'Authorization': 'Bearer BEARERTOKENHERE'
}
response = requests.request("POST", url, headers=headers, data = payload, files = files)
print(response.text.encode('utf8'))
The above works for me and uploads successfully. Something to note though, I have not figured out how to make the upload tied to my account, or within a specific album. It seems to be ignoring the album_id field. In other words, despite using the Bearer token, it appears to be navigating the API "anonymously".
Upvotes: 2
Reputation: 2066
From the imgur Help site, located here and last updated 2 months ago:
File Types
If you need help learning how to upload on Imgur, check out this help article. You can upload any of the following files: JPEG, PNG, GIF, APNG, TIFF, MOV (desktop website only), MP4 (desktop website only)
Imgur doesn't currently support uploads in the following formats: WEBM GIFV
Explicitly, MP4s are only currently supported as uploaded manually via the website directly.
Unfortunately, that means imgur does not support MP4 types through any method other than the Desktop site at this current time.
Upvotes: 1