I have a setup of an android phone connected to a server through a socket, What I need to do is the app will contain a recycler view, each item in the recycler view will have a check-box in it once checked the file that this item represents should be uploaded to the server through a data output stream this will take some time as the files range anywhere between 12-200 MB and a scenario that probably will happen is the user clicking multiple boxes after each other and because I'm using a socket I think I can't send two files at the same time, So I want to queue the files and sort of send each file after the one before it finishes also the files must be sent no matter what the user does f the user exits the app or leaves the app in the background the upload must continue, what approach can I take to achieve this and please answer with code samples of both the queueing the upload in the phone and receiving the files on the server.
Related
I have tried converting media into 'base64' string then tried to send it. But I think for more long string there will be problem to send that string via web sockets. Kindly share better idea for that.
There are 2 options to do the same,
Peer to peer file transfer:
This uses XMPP mechanism of P2P file transfer and is only suitable for when both users are online. We usually recommend using cloud stored file transfer (see below) unless you have concerns / limitations on server-side.
Cloud stored file transfer:
This uses QB Content API to store files when sent by the user and to retrieve them when other user(s) are ready to download them. The user experience is seamless and allows the user to send/receive files even when the other user is offline, the other user can open the conversation any time and download/play the file.
On client side, typically you want to handle things like progress bars, thumbnails for photos and videos etc.
I read this on Quora and it works
i was checking peerflix and it was really awesome that it support seek feature in videos.
i tried to understand how it works , i think it create a stream pipe on HTTP file server and write video data on it when a required piece is downloaded and the video player reads data from other end of pipe.
i tried to do this in java using Pipedinputstream and pipedoutputstream using nanohttpd server but cannot make it work.
is there something i am missing?
peerflix: it is a lib that stream torrent videos , you can watch videos with seek feature. you do not have to wait for the download to finish.
Peerflix selects the biggest file in the torrent or you can select one on your own. Then it begins downloading the file sequentially from the first piece. This file is served on a standard HTTP static file server.
When you seek in a video player, it checks the video container to find which bytes in the video file that corresponds to the given time stamp. The video player then sends a HTTP range request for the bytes corresponding to the video time plus some buffer. Then, Peerflix's HTTP server reads this range request and checks the .torrent file to find which piece corresponds to the requested bytes. It starts downloading sequentially from the requested piece onwards, and responds to the HTTP request when the requested bytes are available.
I have a situation where I need to show the progress of multiple FTP clients which are accessing the same file on a location X in FTP server. I need to show this progress from the server itself, not from the client. (The operation is initiated from the server like the server communicates the client the FTP site user name/password, file location and then the client does a health check of itself and starts a FTP get operation).
I know from the client there is a deterministic way of calculating the number of bytes downloaded with the actual file size so that it would be easy to show that on a percentage or time scale. But I was wondering waht would I do if I need the same capability from the FTP server itself.
I am working on an Android project that will connect to an Xbox 360 controller. I want to be able to capture user feedback via the controller's input reports. I am using Virtual Box and AndroidVM for testing and have used the following for reference to the USB protocol (especially as it pertains to the Xbox controller):
http://free60.org/GamePad
http://www.beyondlogic.org/usbnutshell/usb3.shtml#USBProtocols
To name a few of the links I am using for information. I have also referenced HID protocol information to examine the packet descriptions.
I have successfully been able to detect and enumerate the controller via the VM AND have been successful in obtaining input reports using the Android SDK API (e.g. USBManager, USBInterface, USBDevice etc.), but only by explicitly making a request for the report using a control transfer request.
I would like to be able to pull these input reports via interrupts on the appropriate endpoint. I have attempted to read packets from the first endpoint on the first interface (getInterface[0] and getEndpoint[0]) and I do receive data, but am having difficulty parsing the data in the byte buffer (I have the buffer set as little endian). In particular, how do I know the delimiters for each packet? I know each packet starts with a Sync field and that this Sync is 8bits and the last two bits indicate where the PID starts, but I am not sure exactly what that means. What are Ks and Js as many documents describe for the Sync and how are these represented as bits? Also, all packets are supposed to have an EOP, does this need to be parsed or is this handled by hardware?
I have a regular JSP/Servlet/Java web application that is used for uploading pictures from a mobile device. I am using Apache Commons library for the upload. Application is hosted on WebSphere Application Server 7.0.
Everything is working fine and the user can upload several images totaling 8MB or more if he has a really good/strong signal/connection or on a good WiFi.
The problem arises when the user is at a location with poor 3G/4G signal/connection. He gets errors like "Illegal state exception" or some time-out error, and in some cases the mobile browser just stays on the submit page with the progress bar no longer moving.
Any suggestions on how to "gracefully" handle this? Like is there a way to intervene after a set amount of time and give the the user an option to submit the form without the file attachment (i.e. just submit the form text fields)? Any other suggestions are welcome too.
UPDATE: The setTimeout solution below worked for me. The other missing piece was that I have to issue a "browser stop" command to stop the original submission that's in progress before I can issue a re-submit. Otherwise, my re-submit command will just be ignored by the browser.
The usecase here is simple - if the upload didn't finish in N minutes, remove/clear the field using javascript and resend the form.
You don't need to control the upload in the basic implementation, just safely asume that if you set a timeout to resend, it won't happen if the first attempt was successful and the page reloaded.
jQuery pseudocode:
setTimeout(function(){
$imageFieldNode.remove();
$form.trigger('submit');
},30000);//after 30 seconds
The more advanced way is to use a ready solution for controlled upload. They work like that:
upload starts
js prompts the server in intervals with a GET query to get the size of content that was already received.
everytime it gets the info - it reports progress.
You can do a lot with these libs.
You can think about the approach used in popular webmail clients (when attaching files to a message):
The files are uploaded independently (i.e. before) of the form submit, using javascript. Each of the files are stored in a temporary directory, and after the upload succeeds the user can proceed with the action.
The upload status is displayed to the user, and if it fails the main action (form fill/submit) does not get interrupted.