Rails streaming and uploading at the same page - ruby-on-rails

I have a page where users see the uploaded videos. Above the videos, there is an "Update" form with the ability to upload videos to the collection. The form uses realtime uploading (Upload starts as soon as user chooses file). And when the upload progress is 100%. The user hits "Update" button to update video collection.
The problem occurs when the user wants to upload a file when watching a video. The upload does not progress. There are no messages or errors in server development log or client javascript console. It just hangs (the video continues playing though). The upload usually hangs at the start (5%, 20% depending on the video file size).
By the way; i use refile gem for managing realtime uploads, storage, file serving, etc. Also it should be known that, i use same rails application server (Thin 1.6.3) to serve files and accept uploads. (Maybe the server gets busy and can not accept uploads? Because if i don't start playing the video, the upload progresses smoothly and completes without a problem.)
Could anyone point me in the right direction? Where to look? Are there any parameters i should set somewhere?

Related

How to apply a delayed job or background process in Rails?

I have created a Rails app which uploads a video to a Box account. All works fine when a video is small sized video. However, when video is a big file, I get c9.io's bad gateway error. To avoid this, I wanna add a background process which will upload the video for me, as I have no issue with Box's API's session.

caching mp4 video from the server for use with avplayer

I have a list of videos in my iOS app, which I fetch from my API. The list contains video nodes with an mp4 video file url on the server, and as the user scrolls from one video to the next, the next video starts and the earlier video pauses. This all works well, but I need a way to cache mp4 videos to disk, in such a way that when the user tries to seek, I first try serving the sought chunk from my disk cache, and if this is not cached already, I start loading the chunk from the network, and then the chunks are cached to disk while being played. I also need a way to pre cache the next videos, for example if the user starts playing first video, I need to be able to start caching the second video, so that when the second video starts playing, it does so from the cache, to the point upto which the video is cached, and then seamlessly hop to fetching from the server (and of course caching the responses). How do I go about this?
There's no automated way to do this built into the framework. You'll use background NSURLSessions with download tasks and delegate methods.
You can monitor the progress of the downloads, access the temporary files while they download, pause, resume, and cancel them.

Is it possible to initiate an upload when app is suspended?

Here is the user experience I am hoping to achieve: In my app user can take some photos and upload them to Amazon S3. It is likely that user won't have internet available at that time (nature of app and target market). So I want to store those photos in device if internet is not available and automatically start uploading them whenever internet is available.
And this is where I need help: How can I achieve this? If not completely, how much closer can I get to this user experience? Like stores the photos and start uploading when users opens the app next time or show a notification when internet is available, then user can tap on it to open app and start uploading etc.
Additional information: Each upload will take ~1 minute to complete. After an upload is complete I also need to make an http request (if that matters).
Yes, this is possible. Look into URLSessionUploadTask:
Upload tasks are similar to data tasks, but they also send data (often in the form of a file), and support background uploads while
the app is not running.

Youtube API - Remove Duplicate Rejected as well as Original copy

Every now and then when I push a video through the Youtube API I do not get the success result back to my server with the appropriate video ID. (assuming some kind of random connectivity issue)
This creates an issue where my server assumes the video hasn't uploaded it so it attempts to upload it again. Which then creates a duplicate.
How would I find out and remove any duplicates as well as the 1st uploaded video so I can start the process again and upload a fresh copy?
Is there a way to tell youtube to delete the video if it can not return the ID successfully to my server?
Cheers

Background file upload in Blackberry WebWorks

I'm writing a Blackberry Z10 app for use in onsite events where we take photos or short videos of attendees and the photos are available immediately on a website. We take the photo, enter a message to be displayed with it and the photo gets uploaded right then. We initially used blackberry.io.filetransfer.upload but the videos could be up to 30MB so would have a long wait time, so we switched to an XHR transfer where we could have a progress bar so at least the app user would have something to look at.
We've found that sometimes they're in areas with low connectivity, so would like to just copy the file to a folder that is watched by a background process and anything deposited there gets uploaded to the server. How can we get an app functioning basically as a service, doing file transfers even when minimized?

Resources