Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ff0f99c

Browse files
committed
Updated readme.md
Updated code examples to meet library changes
1 parent 2180561 commit ff0f99c

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ Upload it to your server and pass "uploaded_file" as the second parameter to the
5252

5353
## How to start android upload service to upload files
5454
public void upload(final Context context) {
55-
final UploadRequest request = new UploadRequest(context, "http://www.yoursite.com/your/script");
55+
final UploadRequest request = new UploadRequest(context,
56+
"custom-upload-id", //This is used when receiving upload status
57+
"http://www.yoursite.com/your/script");
5658

5759
request.addFileToUpload("/absolute/path/to/your/file",
5860
"parameter-name", //Name of the parameter that will contain file's data. Pass "uploaded_file" if you're using the test PHP script
@@ -111,18 +113,21 @@ So to listen for the status of the upload service in an Activity for example, yo
111113
private final BroadcastReceiver uploadReceiver = new AbstractUploadServiceReceiver() {
112114

113115
@Override
114-
public void onProgress(int progress) {
115-
Log.i("AndroidUploadService", "The progress is: " + progress);
116+
public void onProgress(String uploadId, int progress) {
117+
Log.i("AndroidUploadService", "The progress of the upload with ID " + uploadId
118+
+ " is: " + progress);
116119
}
117120

118121
@Override
119-
public void onError(Exception exception) {
120-
Log.e("AndroidUploadService", exception.getLocalizedMessage(), exception);
122+
public void onError(String uploadId, Exception exception) {
123+
Log.e("AndroidUploadService", "Error in upload with ID: " + uploadId + ". "
124+
+ exception.getLocalizedMessage(), exception);
121125
}
122126

123127
@Override
124-
public void onCompleted(int serverResponseCode, String serverResponseMessage) {
125-
Log.i("AndroidUploadService", "Upload completed: " + serverResponseCode + ", " + serverResponseMessage);
128+
public void onCompleted(String uploadId, int serverResponseCode, String serverResponseMessage) {
129+
Log.i("AndroidUploadService", "Upload with ID " + uploadId + " is completed: "
130+
+ serverResponseCode + ", " + serverResponseMessage);
126131
}
127132
};
128133
@@ -144,6 +149,13 @@ So to listen for the status of the upload service in an Activity for example, yo
144149

145150
If you want to monitor upload status in all of your activities, then just implement the BroadcastReceiver in your base activity class, from which all of your activities inherits and you're done.
146151

152+
## Using HTTPS connection with self-signed certificates
153+
For security reasons, the library doesn't accept self-signed certificates by default when using HTTPS connections, but you can enable them by calling:
154+
155+
AllCertificatesAndHostsTruster.apply();
156+
157+
before starting the upload service.
158+
147159
## Do you use Android Upload Service in your project?
148160
Let me know, and I'll be glad to include a link in the following list :)
149161

0 commit comments

Comments
 (0)