Comments (12)
Follow the example here: https://github.com/alexbbb/android-upload-service#how-to-monitor-upload-status
@Override
public void onCompleted(String uploadId,
int serverResponseCode,
String serverResponseMessage) {
Log.i(TAG, "Upload with ID " + uploadId
+ " is completed: " + serverResponseCode
+ ", " + serverResponseMessage);
//Use a library such as org.json or google gson
//to parse JSON from serverResponseMessage string
}
from android-upload-service.
Hi, I ‘ve done it at beginning and suppose that serverResponseMessage would be son but NOT. it is representation(key=value) of serverReponseCode.
So I mean that if serverResponseCode is 200-> serverResponseMessage display in debugger(LogCat) OK.
Next, if server/php side set http_response_code(202); then LogCat display serverResponseCode 202 -> and serverResponseMessage: Accepted.
Believe me, I tested serveral times to debug it up and down but could not get json response from server eve I send it from.
I would not bother you if did not read your manual and implementation steps.
serverResponseMessage is only velue representation of serverResponseCode BUT I need json response data that I sent from server side like:
http_response_code(200);
$result['data'] = array(‘picName’=>’abc.jpg’, ’status’=>’OK');
$json = json_encode($result);
header("Content-Type: application/json", true);
exit($json);
Have you tried it, get json response from server to upload service?
Thanks for help, indeed.
Regards,
Ing. Marian Kubincanek
Senior Java Developer
LinkedIn: http://www.linkedin.com/in/mariankubincanekhttp://www.linkedin.com/in/mariankubincanek http://www.linkedin.com/in/mariankubincanek
On Jan 28, 2015, at 09:50, Alex Gotev [email protected] wrote:
Follow the example here: https://github.com/alexbbb/android-upload-service#how-to-monitor-upload-status https://github.com/alexbbb/android-upload-service#how-to-monitor-upload-status
@OverRide
public void onCompleted(String uploadId,
int serverResponseCode,
String serverResponseMessage) {
Log.i(TAG, "Upload with ID " + uploadId
+ " is completed: " + serverResponseCode
+ ", " + serverResponseMessage);
//Use a library such as org.json or google gson
//to parse JSON from serverResponseMessage string
}
—
Reply to this email directly or view it on GitHub #15 (comment).
from android-upload-service.
I've made some modifications to read response body from the server: 140bef1
Please update the library, try again as I suggested you in the previous comment and let me know what you get in "serverResponseMessage"
from android-upload-service.
Hi Alex,
That modification is exactly what I needed(InputStream data) to proceed server response data in android, great it works.
Thanks again. Enj day.
Regards,
Ing. Marian Kubincanek
Senior Java Developer
LinkedIn: http://www.linkedin.com/in/mariankubincanekhttp://www.linkedin.com/in/mariankubincanek http://www.linkedin.com/in/mariankubincanek
On Jan 28, 2015, at 10:54, Alex Gotev [email protected] wrote:
I've made some modifications to read response body from the server: 140bef1 140bef1
Please update the library, try again as I suggested you in the previous comment and let me know what you get in "serverResponseMessage"—
Reply to this email directly or view it on GitHub #15 (comment).
from android-upload-service.
Thank you for your feedback 👍 and I'm glad that everything works now :)
from android-upload-service.
Hi Alex,
Just note. Next customization that I had to do in your upload android service was:
UploadService
getMultipartHttpURLConnection
conn.setRequestProperty("Connection", "close");
// conn.setRequestProperty("Connection", "Keep-Alive”);
http://tiku.io/questions/782960/java-net-socketexception-sendto-failed-epipe-broken-pipe-on-android http://tiku.io/questions/782960/java-net-socketexception-sendto-failed-epipe-broken-pipe-on-android
Cause every 2nd request to send multipart(Picture+data) to server was with exception:
01-11 14:07:24.920: I/CameraActivity(650): The progress of the upload with ID c88f3352-7a39-403f-8351-981b88dd79c3 is: 4
01-11 14:07:25.065: D/dalvikvm(650): GC_FOR_ALLOC freed 2934K, 30% free 13180K/18624K, paused 22ms, total 22ms
01-11 14:07:25.110: E/CameraActivity(650): Error in upload with ID: c88f3352-7a39-403f-8351-981b88dd79c3. sendto failed: EPIPE (Broken pipe)
01-11 14:07:25.110: E/CameraActivity(650): java.net.SocketException: sendto failed: EPIPE (Broken pipe)
01-11 14:07:25.110: E/CameraActivity(650): at libcore.io.IoBridge.maybeThrowAfterSendto(IoBridge.java:499)
01-11 14:07:25.110: E/CameraActivity(650): at libcore.io.IoBridge.sendto(IoBridge.java:468)
01-11 14:07:25.110: E/CameraActivity(650): at java.net.PlainSocketImpl.write(PlainSocketImpl.java:507)
01-11 14:07:25.110: E/CameraActivity(650): at java.net.PlainSocketImpl.access$100(PlainSocketImpl.java:46)
01-11 14:07:25.110: E/CameraActivity(650): at java.net.PlainSocketImpl$PlainSocketOutputStream.write(PlainSocketImpl.java:269)
01-11 14:07:25.110: E/CameraActivity(650): at libcore.net.http.ChunkedOutputStream.writeHex(ChunkedOutputStream.java:102)
01-11 14:07:25.110: E/CameraActivity(650): at libcore.net.http.ChunkedOutputStream.writeBufferedChunkToSocket(ChunkedOutputStream.java:128)
01-11 14:07:25.110: E/CameraActivity(650): at libcore.net.http.ChunkedOutputStream.write(ChunkedOutputStream.java:77)
01-11 14:07:25.110: E/CameraActivity(650): at com.alexbbb.uploadservice.UploadService.uploadFiles(UploadService.java:265)
01-11 14:07:25.110: E/CameraActivity(650): at com.alexbbb.uploadservice.UploadService.handleFileUpload(UploadService.java:166)
01-11 14:07:25.110: E/CameraActivity(650): at com.alexbbb.uploadservice.UploadService.onHandleIntent(UploadService.java:137)
01-11 14:07:25.110: E/CameraActivity(650): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
01-11 14:07:25.110: E/CameraActivity(650): at android.os.Handler.dispatchMessage(Handler.java:99)
01-11 14:07:25.110: E/CameraActivity(650): at android.os.Looper.loop(Looper.java:176)
01-11 14:07:25.110: E/CameraActivity(650): at android.os.HandlerThread.run(HandlerThread.java:61)
01-11 14:07:25.110: E/CameraActivity(650): Caused by: libcore.io.ErrnoException: sendto failed: EPIPE (Broken pipe)
01-11 14:07:25.110: E/CameraActivity(650): at libcore.io.Posix.sendtoBytes(Native Method)
01-11 14:07:25.110: E/CameraActivity(650): at libcore.io.Posix.sendto(Posix.java:155)
01-11 14:07:25.110: E/CameraActivity(650): at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:177)
01-11 14:07:25.110: E/CameraActivity(650): at libcore.io.IoBridge.sendto(IoBridge.java:466)
01-11 14:07:25.110: E/CameraActivity(650): ... 13 more
OR
01-11 14:12:23.165: E/CameraActivity(7394): Error in upload with ID: 7f190d3e-8edc-40fa-a7a3-c6f18c05e6d0. null
01-11 14:12:23.165: E/CameraActivity(7394): java.io.EOFException
01-11 14:12:23.165: E/CameraActivity(7394): at libcore.io.Streams.readAsciiLine(Streams.java:203)
01-11 14:12:23.165: E/CameraActivity(7394): at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:579)
01-11 14:12:23.165: E/CameraActivity(7394): at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:827)
01-11 14:12:23.165: E/CameraActivity(7394): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283)
01-11 14:12:23.165: E/CameraActivity(7394): at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:497)
01-11 14:12:23.165: E/CameraActivity(7394): at com.alexbbb.uploadservice.UploadService.handleFileUpload(UploadService.java:170)
01-11 14:12:23.165: E/CameraActivity(7394): at com.alexbbb.uploadservice.UploadService.onHandleIntent(UploadService.java:137)
01-11 14:12:23.165: E/CameraActivity(7394): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
01-11 14:12:23.165: E/CameraActivity(7394): at android.os.Handler.dispatchMessage(Handler.java:99)
01-11 14:12:23.165: E/CameraActivity(7394): at android.os.Looper.loop(Looper.java:176)
01-11 14:12:23.165: E/CameraActivity(7394): at android.os.HandlerThread.run(HandlerThread.java:61)
OR Socket Exceprion pointing to EPIPE
So to explain:
- 1st android/http request opened socket con, server closed, but service kept opened.
- 2nd request wanted to used before user con->so socket, but exceptionraised cause server do not have before used socket keep alive, closed, ended. Then android/http con closed too.
- 3rd reuest like 1st
- 4th like 2ns, crashed and so on.
It is right to use keep alive connection opened while uploading batch files, I mean 6 pictures in one time, batch upload.
Just note, if other met the same problem ;)
Enj day.
Regards,
Ing. Marian Kubincanek
Senior Java Developer
LinkedIn: http://www.linkedin.com/in/mariankubincanekhttp://www.linkedin.com/in/mariankubincanek http://www.linkedin.com/in/mariankubincanek
On Jan 28, 2015, at 11:29, Alex Gotev [email protected] wrote:
Thank you for your feedback and I'm glad that everything works now :)
—
Reply to this email directly or view it on GitHub #15 (comment).
from android-upload-service.
This error happened also to other users in the past, but none of them gave me a log to work with and an exact step-by-step description of how to reproduce the error. I've reproduced the error you described and by applying your solution, the problem is resolved, so I committed your patch: 60ecf22
Just update the library and you're good to go ;)
from android-upload-service.
I like to help you ;)
Property about uploading should be set before start request like:
enum{
SINGLE_UPLOAD, ->Con close
BATCH_UPLOAD -> Con Keep Alive
}
I customize more yor code and let you know, but fix Con:close works 100%. Now I building/testing one app and works perfect.
Thanks again ;)
Regards,
Ing. Marian Kubincanek
Senior Java Developer
LinkedIn: http://www.linkedin.com/in/mariankubincanekhttp://www.linkedin.com/in/mariankubincanek http://www.linkedin.com/in/mariankubincanek
On Jan 28, 2015, at 14:11, Alex Gotev [email protected] wrote:
This error happened also to other users in the past, but none of them gave me a log to work with and an exact step-by-step description of how to reproduce the error. I've reproduced the error you described and by applying your solution, the problem is resolved, so I committed your patch: 60ecf22 60ecf22
Just update the library and you're good to go ;)—
Reply to this email directly or view it on GitHub #15 (comment).
from android-upload-service.
By batch upload you mean an UploadRequest on which you add more than one file (by calling addFileToUpload N times) or you're making N calls to UploadService.startUpload(request) ?
from android-upload-service.
1option
UploadRequest on which you add more than one file (by calling addFileToUpload)
Regards,
Ing. Marian Kubincanek
Senior Java Developer
LinkedIn: http://www.linkedin.com/in/mariankubincanekhttp://www.linkedin.com/in/mariankubincanek http://www.linkedin.com/in/mariankubincanek
On Jan 28, 2015, at 14:33, Alex Gotev [email protected] wrote:
By batch upload you mean an UploadRequest on which you add more than one file (by calling addFileToUpload) or you're making N calls to UploadService.startUpload(request) ?
—
Reply to this email directly or view it on GitHub #15 (comment).
from android-upload-service.
Ok, so to keep things simple and transparent to the users of the library, I set connection keep-alive only if there is more than one file to upload, otherwise I set it to connection close. Commit: 9a7b35b
from android-upload-service.
exactly ;) good fix
Regards,
Ing. Marian Kubincanek
Senior Java Developer
LinkedIn: http://www.linkedin.com/in/mariankubincanekhttp://www.linkedin.com/in/mariankubincanek http://www.linkedin.com/in/mariankubincanek
On Jan 28, 2015, at 14:40, Alex Gotev [email protected] wrote:
Ok, so to keep things simple and transparent to the users of the library, I set connection keep-alive only if there is more than one file to upload, otherwise I set it to connection close. Commit: 9a7b35b 9a7b35b
—
Reply to this email directly or view it on GitHub #15 (comment).
from android-upload-service.
Related Issues (20)
- memory leak HOT 2
- Actual file size is not matched with upload file size shown in UploadService HOT 3
- Hey Please add support for java or someone give java example with events(ie:onprogress,oncompleted) HOT 1
- Android 13 support Required HOT 3
- Is there any way tto upload multiple files using different url in same nnotification HOT 1
- java.lang.InstantiationException HOT 1
- Initial notification ignores custom notificationHandlerFactory HOT 7
- Stop Observing from RequestObserver using unregister causing a crash. HOT 3
- Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. HOT 6
- Google Play will soon require that apps target API level 33 or higher. This will be required for new apps and updates starting on August 31, 2023. HOT 4
- Single notification about all ongoing uploads HOT 3
- Please add support for Android 34 HOT 4
- Java Code Samples? HOT 1
- How to get uploaded file infomation that returned by service api
- Question: Is it possible to send a HTTP request once an upload task finishes? HOT 5
- Question on crash message when closing the app: Unable to create service net.gotev.uploadservice.UploadService HOT 16
- Missing default constructor for SchemeHandler classes HOT 3
- Incompatible version of Kotlin error after upgrading to 4.9.2 HOT 3
- register gotev receiver HOT 2
- Result of uploading file HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-upload-service.