I want to have my users be able to upload audio files.
I've done some research on this and found Paperclip. However, I've also read that Paperclip performs poorly if the file is over 4MB, and as you probably know most audio files are over 4MB.
So my question is, how can I have users upload audio files without using Paperclip? I plan on storing everything in Amazon S3.
I plan on users being able to stream this audio and download the files, if that makes any difference.
Related
ActiveStorage seems to be mostly focused on images. While it does offer "preview" support to get a thumbnail from a video -- what about "variants"?
With images, maybe it's uploaded as a JPG, but I can use the variants feature to convert to a PNG, and/or resize it, whatever.
But what if I want to do something similar with videos? Let's say the video was uploaded as an mp4, but I want to transform it into webm, or vice versa, or downsample it, or whatever.
How would one do this if one wanted to use ActiveStorage to keep track of the original uploaded file?
I needed something to convert quicktime (mov) files into mp4.
This works locally, but uses way too much memory in production to be useful.
Still, it seems to work, so may help you it you have a lot of RAM to spare.
Example: for a ~4.4mb video, it uses >1GB RAM to transcode it!
# Transcoding quicktime to mp4
if post_params[:files][1].content_type == "video/quicktime"
# Transcode
require 'streamio-ffmpeg'
movie = FFMPEG::Movie.new(post_params[:files][1].tempfile.path)
# Write new movie
require 'tempfile'
tempfile = Tempfile.new(["", ".mp4"])
movie.transcode(tempfile.path)
# Update tempfile path in ActiveStorage
post_params[:files][1].tempfile = tempfile
# Update headers
post_params[:files][1].headers = post_params[:files][1].headers.sub("\nContent-Type: video/quicktime", "\nContent-Type: video/mp4")
end
So what I intend to do is offload these workloads to AWS lambdas, which could be triggered to run when an new file arrives in ActiveStorage.
I will update if I get it working successfully.
I have a small webapp that runs on a server intended for use in a setting without reliable internet access (i.e., the app can't depend on outside resources during production). The purpose of the app is simply to upload image files, read the metadata, and categorize them in the right location on the disk. Up until recently there was no problem with this process, then I noticed that some of the files did not have all of the metadata attached (specifically the creation date). Upon further inspection, it appears that these are files that were shot on my iPhone as HEIC/HEIF photos and uploaded directly to the webpage from the phone.
Due to the design of the webapp, the filename of the uploaded file is shown on the page. Every time an HEIC photo is uploaded it displays the filename as ending in .jpeg.
I've had a hard time finding good documentation on this, but it sounds like the default for the iPhone at this point is to convert HEIC files to jpeg if it looks like they are transferring to a location that may not be able to read them. I guess a website form falls into this category. It also appears that as part of this conversion some of the EXIF data disappears.
So, does anyone know a way to retain the EXIF data? My primary limitation here is that the upload needs to happen through the webapp and that multiple users will be using this. As a result, I can't simply have everyone change their iPhone settings to only shoot jpegs.
In case it matters, the webapp is running on node.js and expressjs.
Working with Grails 3.* Framework.
Iam trying to upload a video file, the size will be grater than 10 MB.
Below is the code, which works perfectly for storing image files in server, which is uploaded from client browser
File fileIns = new File("/opt/a.jpg")
fileIns << params.image
Can I use the same code for saving videos.
if so, params.video may consume a huge memory, how can I optimize it.
Or any other methods to stream part by part and save it as video?
How whatsapp and telegram are used for transferring video files into the server?
Any suggestions is appreciated.
If You are dealing with large data, I'd suggest going full java.
Check this link about using Streaming.
Another chance is using HTTPClient. Read this
I want to be able to routinely upload about 3x 20mb files to a specific type of record in a Rails app. So far I'm using Paperclip and I get a pretty average success rate and a lot of EOF (bad content body) errors.
What can I do to improve the situation? Googling rails large upload doesn't turn much up.
Uploading large files, while slow, should succeed. The EOF (bad content body) error seems unrelated.
What are you using to upload the files? A standard multipart web form? And is anything unusual happening with the server configuration? Or are you using POW? Apparently POW users have reported similar issues.
For large files, I typically use S3 for storage and would recommend uploading directly to S3.
(Rails 3.2 on Heroku)
For handling image uploads in Rails I switched from Paperclip to Dragonfly because I like to be able to generate thumbnails dynamically, when they are requested for the first time.
However, it seems that uploading of attached files to S3 (using S3DataStore) is much slower than with Paperclip
This is how an upload looks in a NewRelic transaction trace:
Anyone have experience in speeding this up?
That's a really surprising benchmark; is the server doing the file uploading on EC2 and also in the same region as your S3 bucket? How big are the generated thumbnails?
Those questions aside, doing any kind of thumbnail generation during a response is probably not a great idea: it'll add some time to each page load where thumbnails need to be generated, and even if that time isn't 3 seconds it'll still be something. I'd process images asynchronously with a gem like Delayed Paperclip. Though you won't save on storage space, as you would with CarrierWave, your response times will be vastly improved.