AWS presigned URL fails when the video is longer than 1 minute - node.js

I tried creating a presigned URL for two videos in the same s3 bucket manually and I've set the expiration date to 7 days :
The first one (47,3 MO and 20 seconds long) is working perfectly.
First video url output
The second video (82,3 MO and 6 minutes long) is not working : It shows no error in the console
Second video url output
It is the same issue even when I use a lambda function to generate the presigned URLS.
My lambda function code in NodeJS
I found this issue that can help me but it's not solved either :
S3 presigned url fails when large files

Turned out it's the video's problem. the videos I was using were timelapes converted to MP4 and I guess the format wasn't right that's why it's not supported by S3

Related

Can we upload media files using URL in MediaFileUpload?

Basically all I want to know is, I am working on Youtube API to upload videos on my channel. Whenever I try to upload video from my local file, it works without any issue. But if I want to upload some videos which are already hosted on S3, it gives me error related to OS i.e. OSError: File not found at that location.
So is there any way to upload video using youtube API from already hosted URLs ?
P.S. I am following the documentation of youtube API and using MediaFileUpload to upload the video files.
Edit 1: I tried a minor hack around this particular issue and works fine for me. Just leaving it here for future developers.
import requests
from six import BytesIO
url = "" # The video url you want to upload (I use S3 urls, not sure if it will work with youtube urls)
res = requests.get(url)
file = BytesIO(res.content)
media = MediaIoBaseUpload(file, mimetype="application/octet-stream")

How to upload an mp4 (or other video) to Imgur using the API?

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
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".
From the imgur Help site, located here and last updated 2 months ago:
https://help.imgur.com/hc/en-us/articles/115000083326-What-files-can-I-upload-What-is-the-size-limit-
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.
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

Unable to download video from Google Photos API baseUrl

I am trying to download a video from {baseUrl=dv}. ( URL 1 )
After that the page on this URL was redirected and getting a 500 error ( URL 2 ).
What's missing?
There is currently a known issue with base URLs for videos. Accessing the video via the dv parameter returns a 500 Error.
You can follow along on the issue tracker here: https://issuetracker.google.com/111638708 ("Star" the issue to be notified of any updates.)

Can I GET from private bucket from Lambda using curl without presigned url?

On my Lambda I am using binary programs for audio conversion, like curl {urls} | converter - this is a good approach because curl stream files and converter transcode them during fetching. I used presigned urls but faced with a problem that when Signature param contains + (and maybe =, /) I get 403. I tried curl '{urls}' and %2B instead of + - no luck. My current code validates presigned url for + and if found - wait one second and generate new presigned url, but waiting on Lambda is non-free.
My Lambda has the policy for getting files from this bucket - but looks like only through presigned urls.

Messenger Send API + AWS S3 hosted object

I have an png uploaded to an S3 bucket with public read permissions. When I use the Messenger API to send it, I get the following error:
Messenger Error received. For more information about error codes, see: https://developers.facebook.com/docs/messenger-platform/reference/send-api/error-codes
{ message: '(#100) Failed to fetch the file from the url',
type: 'OAuthException',
code: 100,
error_subcode: 2018008,
fbtrace_id: 'F8w/11MzB9B' }
My S3 url is in the format https://bucketname.s3.amazonaws.com/filename.png, and when I visit it, it works BUT results in auto-download. Does Messenger expect a displayed image? If so how might I change the S3 settings to permit this.
Thanks all!
The problem was that Messenger doesn't accept png file types, despite me seeing examples of png's being sent in the documentation :(.
Sending a jpeg instead works.
Making sure that the S3 object was uploaded with a Content-Type specified and public read permissions (or pre-signed URL) is important.
EDIT: works but doesn't work with pre-signed requests

Resources