Generate thumbnail for multiple file formats - node.js

For the purpose of creating thumbnails for files like pdf, jpg, and docx, I'm looking for a library or service. My server stores data on GCS, and the front-end application should only display brief file previews.
If the thumbnail doesn't already exist, I'd like to create it, save it to gcs, and serve it with a signed url.
I found a few solutions:
filepreview-es6 library - updated 5 years ago
filepreviews.io - external service - the data are confidential
gotenberg.dev - returns only pdfs
How to implement this feature in 2022?

Related

How to generate a one-time download link in Node.js?

I would like to generate a one-time download link in Node.js and email it to the user so he/she can download it. I would want the link to expire after a while, say one day or one week for example. How can I do this using node.js?
Thanks!
I can download the file using res.download but it sends the file directly to the client and do not generate download link.
This depends on where are you saving the file.
If you just save the file in your own server, then if you save the file in a static folder you can expose the file through your server's link.
This explains it "uploading File to a static folder in the Server" https://www.bezkoder.com/node-js-express-file-upload/
Now, you also want to expire the link. This would be more complicated since now you have to store the timestamp with respect to a link in the database and make the link invalid when the allocated duration passes.
This all is done by amazon s3 so if its possible to use that you should use it instead of implementing everything.
In aws s3, you can store your file and generate signed links that expire after a duration.

Upload .VTT captions with Azure Media Service video streams

I am trying to achieve uploading an MP4 video to Azure Media services; making it available for streaming via a streaming URL, as well as more importantly and specifically to this question: upload .VTT captions to be shown within the video.
I have worked on integrating the code within this tutorial, more specifically the EncodeAndStreamFiles sample app (described in the document) as a DotNetCore API.
I have managed to retrieve a list of streaming URLs for the Video, and the stream works well (the video is playable).
The next step is uploading a .VTT caption (or subtitle). Unfortunately, I have not found any official documentation from Microsoft regarding this subject. This Stack Overflow question is the only useful information I found. Based on the answers to the question; I am uploading the caption within the same blob container as the video's output asset and referring to it by editing the video's streaming URL (replacing the last part).
So if the video's streaming URL is this:
https://azuremediaservicename-euwe.streaming.media.azure.net/2e262dca-23d9-453d-be00-6a7e60167ab7/HR%20documents.ism/manifest(format=m3u8-aapl)
Then the caption's streaming URL would be:
https://azuremediaservicename-euwe.streaming.media.azure.net/2e262dca-23d9-453d-be00-6a7e60167ab7/HR%20documents.vtt
I am trying to display the video and the caption using the advanced options within this tool. The caption appears within the options, but the actual words don't appear on screen.
I have 2 questions -
Is the uploading of the Caption as part of the blob container, the correct way to upload captions? Or is there a better way (perhaps via the SDK) that I haven't run into yet?
If the answer to 1. is Yes, how should the streaming URL for the caption be generated? Is the example shown above correct?
If you want to store the VTT file in the same storage container than the asset, and make it available as download, then you need to change the predefined policy to
StreamingPolicyName = PredefinedStreamingPolicy.DownloadAndClearStreaming
in line https://github.com/Azure-Samples/media-services-v3-dotnet-tutorials/blob/master/AMSV3Tutorials/UploadEncodeAndStreamFiles/Program.cs#L403
This approach works for clear content but not for protected (DRM) content. For protected content, you should use a separate container (or asset) for the subtitles files.

Is image or file being always downloaded from Google Cloud Storage on click?

Please help me to understand the following, I have a node.js app which I want to run on Google Cloud App Engine, this app will contain some images which are planned to be stored on Google Cloud Storage. On my sample app once I upload an image and get a url (mediaLink or selfLink) image is being downloaded.
Why is that? Each download each click costs money I understand google, but is there any way to make url just show images NOT to be downloaded?
Saving a file from Google Cloud Storage is the same as displaying it. Both action require transferring the content of the image to the device for display or saving.
The action of displaying an image or popping up a save as dialog is controlled by HTTP headers. For example if you have the HTTP header content-type set incorrectly (not as an image) then some browsers will save the file. If you want your image files to be displayed as images set the headers correctly for the type of picture. For PNG files set the header contenty-type: image/png.
You can also force a download with the content-disposition: attachment header.
In summary, it does not matter if you are displaying an image or saving it to local storage, it will cost you money. Both actions requiring downloading (transferring) the contents of the file across the Internet.

Uploading user images to s3 and generating thumbnails from node

I'm currently considering developing a Meteor node.js app, but am struggling with how best to handle uploading of user images. In particular, I want to create a photography website that will allow the photographer to upload images in an 'admin' section, and these images will then be displayed on the website. I need to create a thumbnail of these images, and save the respective URLs to the database. I'm struggling with how to best accomplish this in meteor.
Is my best bet to use something like s3 combined with an AWS process for generating thumbnails?
Or should I save and host the images directly in the Meteor/node session?
Or should I scrap Meteor and use something like Express.js for this project?
Why don't you just use something like Filepicker.io to handle uploading and hosting images and simply store the image unique url (given to you by filepicker in the callback)?
Thumbnails can also be dynamically generated by Filepicker (using simple url modifications).
Cloudinary is a nicer alternative to filepicker when it comes to images, but integration process will be messier.
I would store the images on the filesystem, not in a database. If you have a unique id, you can use that as part of the url, for example an id of the item the image belongs to. Might look like this:
./uploads/img-<id>-<size>.jpg
You can write to disk and resize if necessary with node-imagemagick and your cdn should just poll these images from time to time. Not exactly sure how that part would work in terms of including the url to the image in the html.

Uploading multiple large files via a browser and verifying the upload

I need to allow web users to:
upload multiple files via a browser
upload large files (> 2GB)
verify the upload was not corrupted
I've seen recommendations for Uploadify and Jumploader, however, it isn't clear to me if these applications verify the uploaded file (such as, comparing MD5 of client-side file vs. uploaded). The application must support event hooks prior to and post upload. Any suggestions?

Resources