I want to upload a file (picture) to the server (PHP script), but in background. I am searching a very lightweight AsyncTask to do this, but I can't find any useful on Google.
Any Idea how I can upload a file to PHP with an AsyncTask? The upload Function should only get the local file as variable, every else should be not variable...
Maybe somebody can help me with that?
To perform task in background.
You need to create the service and write the logic in that to upload the file to server.
Read here.
Related
I want to download something from webservice using ASYNCTASK
http://developer.android.com/reference/android/os/AsyncTask.html
and then handle the inputstream and cut some parts LV and pass it to another device via bluetooth. Is it possible with Async task to do it? Unless, there is anyway to store the data received by AsynTask and be able accessing to it after? Or saving it into file and read it after ? (I don't have really experience in Android)
If there is a solution or an example it would be great :)
I'm working on an android app, and I can actually get a list of all my files, but can't use the URL to open a file from the list, I also tried to open from InputStream, but this does not work.
What I want to do is something like ES File Explorer does, I know they use JCIFS library, and that when you open a file (an MP3 for example), they make some kind of Tunnel with sockets, that reads the file and pass it to the propper app in an HTTP format.
Example:
If my nas file path is:
smb://My_IP_Address/SharedFolder/Media/MyMusic.mp3
ES File Explorer send an URL like this:
http:// 127.0.0.1:59777/smb%2FMy_IP_Address%2FSharedFolder%2FMedia%2FMyMusic.mp3
Sorry, I want to use comment instead of answer, but I don't have enough reputation...
What I found on ES Explore or other same app, they seemed not only use JCIFS , but also use nanoHTTPD...
They transfer the nas file to samba file, then use nanoHTTPD as a Streaming server to serve the multimedia files...
There got many sample on the web, here a discussion =>
How to serve a file on sdcard using NanoHTTPD (inside Android)
Hope this can help you...
It's off course doable but kind of tricky. Your app must act as a server, reading an input stream from the samba share, streaming it to a third party application like a music player if we are talking about a mp3 file.
You'll find details here : Android ServerSocket programming with jCIFS streaming files
I need to upload file to my web application using servlet, the problem is that I want the file to be available only in the run time !
I know to upload the file to the server, but I need the file to be available when the user upload the file to the web and do some tasks to the file and when he close the web application he will lose the file and need to upload it again
Would you please give me any tutorial to help me?
I think what you need is a javax.servlet.http.HttpSessionListenerthat delete the file when the user session is destroyed (see method sessionDestroyed(HttpSessionEvent se))
Hope it helps.
Say I have an image file that is located in http://a.com/example.jpg
Then I have a network storage called http://b.com/
Using java, how can I move example.jpg directly to b.com?(Kind of like P2P??)
EDIT
I think I should explain a little bit more.
I want to move file example.jpg to b.com without downloading the file.
Normal approach will be
Open connection to a.com
Download example.jpg to my computer (either memory or disk)
Open a new connection to b.com
Upload the example.jpg to b.com
However, I think this involves unnecessary work.
What I want is this
Open connection to b.com
Without opening connection to a.com, upload example.jpg directly to b.com (I think this is the part where I thought of P2P)
Is there any way that I can do this?
There is no general way to do what you ask merely with HTTP. You would have to have specific support for such operations on the server hosting your network storage, such that you can request it to download URLs directly.
You can get the image using HttpClient from a.com and then upload it to b.com. How do you upload it b.com depends on what you have there.
To be able to do this without downloading the file you will need specific support on b.com. That specific support will be a service on b.com where you send a "download" request and the server will download the file itself from a.com.
We have a web application that allows user to download a zip file from a web server. We just provide dummy iframe source to the full URL of zip file on web server. This approach would allow end user to use browser controls which allows the user to open or save the zip to user's local machine.
We have a requirement that the zip file is automatically extracted and save to a specific location on user's machine. Any thoughts on how this can be achieved?
Thanks.
I highly doubt that you'll be able to do that. The closest you're likely to get is to generate a self-extracting executable file (which would be OS-dependent, of course).
I certainly wouldn't want a zip file to be automatically extracted - and I wouldn't want my browser to be able to force that decision upon me.
Short answer is I don't believe this is possible using the simple URL link you've implemented.
Fundamentally the problem you have is that you have no control over what the user does on their end, since you've ceded control to the browser.
If you do want to do this, then you'll need some client-side code that downloads the zipfile and unzips it.
I suspect Java is the way to go for this - Javascript and Flash both have problems writing files to the local drive. Of course if you want to be Windows only then a COM object could work.
Instead of sending a zip file why don't u instruct the web server to compress all the web traffic and just send the files directly?
See http://articles.sitepoint.com/article/web-output-mod_gzip-apache# for example.