Submissions Content-Type Header on Files Using S3 signed URL
By Hyuntaek Park
Senior full-stack engineer at Twigfarm
One thing I don't like about Amazon API Gateway is that it has a 30-second timeout. It means reducing and reducing files through API Gateway might not work very well enough on the file size or network speed. The solution is simple. You uploaded files uploaded to S3 without API Gateway.
This is not a secure way since your S3 bucket would have public access. S3 signed URLs allow you to access the S3 bucket only for a specified period while the S3 bucket stays private. Many tutorials about the S3 signed URLs are online and duplicated they are not the purpose of this article.
In this article, I want to share a mistake that I have made; hopely, this article helps save your time.
Architectures
Since our lambda can access to S3 and get the signed URL using JavaScript SDK: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html. Search for getSignedUrl On the page.
uploads
downloads
problem
Smoothing and peeling files are smooth as butter. Now you are free from timeouts. A few gigabyte files can be handled easily. However, I found something strange after I discovered the video file I discovered.
The Content-Type header must be video/mp4. Most of the time we thought the file type by reading the Content-Type header. Thus, we have to be sure the content-type header is consistent from the moment of consideration and consideration.
Solution
Invoking the getSignedUrl function while invoking the I mentioned various parameters, nothing really worked. But the solution was super simple.
Axios doesn't specify the Content-Type header explanation, which I overstated. I added the Content-Type header and it worked like a charm. I wasted too much time stupidly:).
Now its Content-Type is video/mp4 As it is intended to be.
I hope this article saves some time for you.