How to cancel HTTP file download? - file

Right now, I am working on a web project(HTML + CSS + JavaScript) using PhoneGap to release APP to android device.
There is a page contains attachment. When user click the attachment link, the user can download it. While the attachment can be very large, the user would cancel the download if he like.
Our program sends HTTP request to the backend to get the attachment.
I just wonder how can I cancel a ongoing download?
Can it be done in front end using Javascript or any PhoneGap API?
Or it can be done in the backend?
I know when you download file from website using chrome, chrome its self can cancel the ongoing download, how chrome does that?
Any information will be appreciate. Thanks a lot.

As a matter of fact, when you want to download file, you should use PhoneGap API class FileTransfer.FileTransfer contains abort function can cancel the ongoing download.
http://docs.phonegap.com/en/1.0.0/phonegap_file_file.md.html#FileTransfer

Related

React Native Upload to YouTube

I am trying to upload a video that I take locally using react native camera and then send it to youtube for processing and then want to display that video on a react.js web dashboard.
We have tried using fetch-blob to upload the video and cloud firestore to store the video. We are not sure at a high level on how to go about the uploading to youtube. I know there is upload docs, however can we physically go about uploading straight from our react-native project to youtube, or would we have to upload to a database such as firebase and then use a cloud function to send it to youtube? Has anyone attempted this? The other alternative is that we can upload to S3 and then use AWS cloudstream to play back but that seems like overkill if there is a simple youtube upload that we can use. Do we have to authenticate a user to youtube before it would work? We do not want anyone having to log into a google account. We are hoping just to have an application created with youtube that we can upload to our channel.
Thank you!
Answer
You can absolutely upload a video to YouTube in many different ways. You mentioned a few options and I will line out how those could work for you.
Do we have to authenticate a user to youtube before it would work?
You will have to authenticate to YouTube in order to upload to a YouTube account. You could very well have one account for your app to use and when your users make videos the app could upload them directly to that account. I do highly advise against that though. Google is not very forgiving and the second someone uploads something to violate Google Policies I suspect you will be banned.
That leaves me to believe the best way here would be to use Auth0 to authenticate users and upload to their accounts. Otherwise maybe look into other options.
Possible Options
Option 1
It might be possible to upload all the videos to one YouTube account and make them all private. Then retrieve those videos and play them on your own site. Possibly something like that could work but it is probably a long shot. That could at least keep you from getting banned because of a user violating Google Policies.
Option 2
Another option would be to make one YouTube account. Save the videos to your server when the users creates them from your mobile application. Then have a waiting period for the video to post to YouTube in order for you and your team to have time to approve them.
At least this way you can use YouTube and have one account, but not take the chance of any repercussions from the videos people are posting.
Problem
How to upload a video from your mobile app using React Native to youtube.com
Solution 1
Upload straight from React Native. You can Use the Google APIs to upload directly to youtube. Google has an extensive API. You will have to create a Google API account and make sure to activate the APIs you want to use. Here is some information I found using the Google Javascript API to work with Youtube.
If you go to this link you can see some information on the scopes of this API.
Here is one scope mentioned on that page.
https://www.googleapis.com/auth/youtube.upload
Using Gogoles APIs you can upload videos directly to the youtube account.
Solution 2
The second solution is to post the video to your server, then once it hits the server use some other server side language to interact with Google's API. This could come in handy for other reasons. Like if you are better with a language other than JavaScript. For example Python might be your favorite language. In that case here is a Python Github repo that does just what your trying to do.
You could very well implement the repo mentioned above to your server and post the video you create from your phone to the server. Allowing the Python script to handle posting the video to YouTube.
Side Note
I do not think Firebase or really any database is necessary for the task you are trying to accomplish. Unless there are other requirements to your problem you have not mentioned.

Ionic + ng-Cordova file transfer with Django

I am developing an Ionic hybrid app and one of the features is taking/choosing a picture and uploading it to the server. I found plenty of examples of how to use $cordovaFileTransfer plugin. The problem is that my backend is in Django and I don't really understand how to process the upload request from the cordova plugin.
Any help or a small example would be appreciated. Thank you.
$cordovaFileTransfer is only the Ionic wrapper for the cordova file transfer plugin. The documentation says:
The FileTransfer object provides a way to upload files using an HTTP multi-part POST or PUT request, and to download files as well.
Since these are simple http POST requests, you don't need nothing special but only the Django file uploads documentation that contains a well documented example.

how to upload files in cpanel file manager via xmlapi

I developing an application which has static content builder for HTML pages. I am able to create ftp account and addondomain in cpanel via xmlapi but I dont know how to upload it in cpanel file manager. I want to know api1 or api2 syntax for file uploading in cpanel. Please help me. I am waiting for your response. I am using PHP for backend programing.
There should be an Upload button on the main toolbar (see here - http://blogerr.net/getting-started-with-file-manager-in-cpanel/ ). If you can't see it, you may need to reset your cPanel configuration...

Need to run the download when the application run in background

I have downloaded 300 images in my application and store it in isolated storage using http request from a server.The problem we are facing is when navigate out form the application by pressing windows button or anyother way. the download stops.We need to run the download continously without errors even the application goes background. kindly guide me
Take a look at the Background File Transfer API. It allows you to queue up one or more file uploads or downloads over HTTP that will be executed in the background, even when the application is no longer running in the foreground.

Internet Explorer download notification on HTTPS

I have a Silverlight application deployed on a HTTPS server. My applications generates reports that are saved as PDF files. Whenever a user tries to download a file from my application from IE, he gets a notification under the toolbar asking him if he really wants to download the file. If you agree, then IE reloads the page, sending the user back to the login page of my application. After logging again, the user can download any file, but this is very annoying for the user. How can I resolve this problem? Thanks!
If you know who your users are (condition), you might ask them to put your website under their list of Trusted Sites, which will avoid the annoying notification bars.
You need to trigger the download in such a way that it's obviously a user-initiated action. I'm not sure if Silverlight offers a method for this.

Resources