Current way to download large files in rails - ruby-on-rails-3

I used to use the method outlined by Obie Fernandez to download files:
http://www.therailsway.com/2009/2/22/file-downloads-done-right/
But this way is a bit outdated so curious what is better? My fear is if you have multiple clients downloading large files too much memory would be eaten up.
I need to camo the S3 url and control who can download what. Perhaps this method is still fine or maybe streaming is the way to go.
Thanks in advance.

Related

Stripping a pdf file from videos

I have a huge pdf file (152M) containing embedded videos. I reckon most of its size must come from the videos themselves. I want to make a lighter version out of it so that it's easier to share and send around, so I would like to remove the videos.
Is there a simple way to do it? In particular, using free tools? Possibly a one-off solution without needing to remove the files one by one?
I thought of using imagemagick for it, but I can't find how and I'm not even sure it's possible
Well, I could not find a way to do it. However, my original problem involved a pdf exported from a pptx presentation, so I managed to remove the videos from the presentation.
This does not answer the presentation, but I had opened a parallel question on askubuntu.com, I'll put the link here if anybody is interested: https://askubuntu.com/questions/1453755/stripping-a-pptx-presentation-from-videos-in-libreoffice-impress/

video/mp2t browser live streaming support

Is there any way we could live stream "video/mp2t" content in the browser? I'm building a live stream app where some urls don't have any mimetype specified but the content is "video/mp2t". I've tried to use the major html 5 players: jwplayer, shaka-player, video.js, and none of them seem to support this kind of content out of the box. I've read that might be possible to transmux on the fly to mp4, do you guys know any example or some guidelines?
Android and ios seem to support this but the browser not, why is that? Do you think it's something to be incorporated in the future?
Thanks!
I've read that might be possible to transmux on the fly to mp4
Yes, you can write the code yourself, or base it on a another library like mux.js. But as you said, nothing does this out of the box.
Android and ios seem to support this but the browser not, why is that?
There are dozens or hundreds of container formats. Supporting them all would be ridiculous. Different companies, and different standard bodies make different decisions on what they think their users will require.
Do you think it's something to be incorporated in the future?
No, I don't.

Assets (JS/CSS) automatic optimization

With the tools we have today for assets optimization (for example YUI compressor), how do you automatize it?
For example, I have designed a new website using LESS, so every time I have to edit CSS I have to manually convert them to LESS. The same for Javascript.
So I have to make my PHP project to point to my uncompressed CSS/JS, and when I'm finished, I compress/optimize them, and point my project to the optimized ones again.
I know that there are tools that helps with this (like less.app, which I've used), and that even there are PHP libs that manage all this problem (like Assetic), but I don't like them much. I'm searching for a "programmed" way to deal with optimized assets. Maybe some script that "watches" the uncompressed files or something...
I wish I could have too many alternatives as the Django framework has.
Please, if the question is not well redacted, tell me and we can improve it, so we can establish a good practice for assets :)
I think one efficient solution would be to do this task on the development side, when writting code, and point the code to the optimized files.
One tool that seems to work well is Live Reload (only for OS X, although there is a Windows version on the way).
I like this option as there is no overload on the code to maintain assets.

Embedding PDF on website - without uploading to other service

On our site we use Google's document viewer to let users view PDF and other documents in the browser. But Google's viewer is not very good, when used without being Google. Quite often it doesn't show anything, and the limit for the PDF file is around 10/20mb. The main issue is that it quite often just doesn't show any files.
So, we're looking for a way to show pdf (and other documents) on our site. It would be great if it could be done without us having to upload it to another service as this complicates the process.
The pricing is not an issue, so even if you know an expensive service, it would be great to let us know.
Or if anyone has other solutions then it would be great to hear of that too.
Thanks,
Tobias
Through another source we were suggested to use Scribd, and our first tests shows that it works great. The documentation is good-ish so it's easy enough to set up.

are there best practices or tricks for indexing/monitoring a drive for files?

I need to find and monitor all the photos on a hard drive or a folder for a photo organizer. Currently I'm doing this naively: recursively traversing, manually marking folders as indexed, and repeating that process to catch when photos are added or moved.
The problem is with a large enough folder tree this is very expensive, so I'm looking for tips to do this differently and/or tips on keeping it a low cpu process.
Ideally solutions would be not platform-dependent.
EDIT: I'm using xulrunner currently, but could compile a module do platform specific stuff.
What about the first run? Is there no solution (even platform-dependent) besides running through the entire folder tree manually.
Ideally solutions would be not platform-dependant.
Impossible. The Win32API has FindFirstChangeNotification, Linux has inotify (and others), Mac OS X has FSEvents, et cetera. This is stuff that's very low-level, and no OS does it the same as any other OS. If you want something cross-platform, you have to find an API with several backends that works on the platforms you want, but if there are any of these, I haven't yet found them.
I don't know of a way to do this in a platform independant way, but on Linux I'd hook into inotify to call something when a file gets added or updated. You could even use inotify-tools to run a script when that happens, so you don't have to be running all the time to capture all these events if they're infrequent. Just have the script update the database, and optionally notify your gallery/display program if it's running.
Are you coding on .NET? If so, you could use the FileSystemWatcher class instead.
Why not user a filewatcher program, which will notify you of changes in particular folder trees?
If you want to write your own you could use the FileSystemWatcher class to do it.
One answer as of 2014 is facebook's watchman: https://facebook.github.io/watchman/
A couple of years ago I ported some functions of Windows API to Linux like (FindFirstChangeNotification, FindCloseChangeNotification ...) it has some limitations but for what you need it could be enough, please take a look at: https://github.com/paulorb/FileMonitor