9
9
10
10
/**
11
11
* Represents an upload request.
12
- *
12
+ *
13
13
* @author alexbbb (Alex Gotev)
14
14
* @author eliasnaur
15
- *
15
+ *
16
16
*/
17
17
public class UploadRequest {
18
18
@@ -29,13 +29,13 @@ public class UploadRequest {
29
29
* Creates a new upload request.
30
30
*
31
31
* @param context application context
32
- * @param uploadId unique ID to assign to this upload request.
33
- * It's used in the broadcast receiver when receiving updates.
32
+ * @param uploadId unique ID to assign to this upload request. It's used in the broadcast receiver when receiving
33
+ * updates.
34
34
* @param serverUrl URL of the server side script that handles the multipart form upload
35
35
*/
36
36
public UploadRequest (final Context context , final String uploadId , final String serverUrl ) {
37
37
this .context = context ;
38
- this .uploadId = uploadId ;
38
+ this .uploadId = uploadId ;
39
39
notificationConfig = new UploadNotificationConfig ();
40
40
url = serverUrl ;
41
41
filesToUpload = new ArrayList <FileToUpload >();
@@ -49,26 +49,19 @@ public UploadRequest(final Context context, final String uploadId, final String
49
49
* @param iconResourceID ID of the notification icon. You can use your own app's R.drawable.your_resource
50
50
* @param title Notification title
51
51
* @param message Text displayed in the notification when the upload is in progress
52
- * @param completed Text displayed in the notification then the upload is completed successfully
52
+ * @param completed Text displayed in the notification when the upload is completed successfully
53
53
* @param error Text displayed in the notification when an error occurs
54
- * @param autoClearOnSuccess true if you want to automatically clear the notification when the upload gets
55
- * completed successfully
56
- */
57
- public void setNotificationConfig (final int iconResourceID ,
58
- final String title ,
59
- final String message ,
60
- final String completed ,
61
- final String error ,
62
- final boolean autoClearOnSuccess ) {
63
- notificationConfig = new UploadNotificationConfig (iconResourceID ,
64
- title , message ,
65
- completed , error ,
54
+ * @param autoClearOnSuccess true if you want to automatically clear the notification when the upload gets completed
55
+ * successfully
56
+ */
57
+ public void setNotificationConfig (final int iconResourceID , final String title , final String message ,
58
+ final String completed , final String error , final boolean autoClearOnSuccess ) {
59
+ notificationConfig = new UploadNotificationConfig (iconResourceID , title , message , completed , error ,
66
60
autoClearOnSuccess );
67
61
}
68
62
69
63
/**
70
- * Validates the upload request and throws exceptions if one or more parameters
71
- * are not properly set.
64
+ * Validates the upload request and throws exceptions if one or more parameters are not properly set.
72
65
*
73
66
* @throws IllegalArgumentException if request protocol or URL are not correctly set
74
67
* @throws MalformedURLException if the provided server URL is not valid
@@ -82,7 +75,7 @@ public void validate() throws IllegalArgumentException, MalformedURLException {
82
75
throw new IllegalArgumentException ("Specify either http:// or https:// as protocol" );
83
76
}
84
77
85
- //Check if the URL is valid
78
+ // Check if the URL is valid
86
79
new URL (url );
87
80
88
81
if (filesToUpload .isEmpty ()) {
@@ -92,21 +85,20 @@ public void validate() throws IllegalArgumentException, MalformedURLException {
92
85
93
86
/**
94
87
* Adds a file to this upload request.
88
+ *
95
89
* @param path Absolute path to the file that you want to upload
96
90
* @param parameterName Name of the form parameter that will contain file's data
97
91
* @param fileName File name seen by the server side script
98
- * @param contentType Content type of the file. Set this to null if you don't want to
99
- * set a content type.
92
+ * @param contentType Content type of the file. Set this to null if you don't want to set a content type.
100
93
*/
101
- public void addFileToUpload (final String path ,
102
- final String parameterName ,
103
- final String fileName ,
94
+ public void addFileToUpload (final String path , final String parameterName , final String fileName ,
104
95
final String contentType ) {
105
96
filesToUpload .add (new FileToUpload (path , parameterName , fileName , contentType ));
106
97
}
107
98
108
99
/**
109
100
* Adds a header to this upload request.
101
+ *
110
102
* @param headerName header name
111
103
* @param headerValue header value
112
104
*/
@@ -116,6 +108,7 @@ public void addHeader(final String headerName, final String headerValue) {
116
108
117
109
/**
118
110
* Adds a parameter to this upload request.
111
+ *
119
112
* @param paramName parameter name
120
113
* @param paramValue parameter value
121
114
*/
@@ -125,6 +118,7 @@ public void addParameter(final String paramName, final String paramValue) {
125
118
126
119
/**
127
120
* Adds a parameter with multiple values to this upload request.
121
+ *
128
122
* @param paramName parameter name
129
123
* @param array values
130
124
*/
@@ -136,6 +130,7 @@ public void addArrayParameter(final String paramName, final String... array) {
136
130
137
131
/**
138
132
* Adds a parameter with multiple values to this upload request.
133
+ *
139
134
* @param paramName parameter name
140
135
* @param list values
141
136
*/
@@ -147,6 +142,7 @@ public void addArrayParameter(final String paramName, final List<String> list) {
147
142
148
143
/**
149
144
* Sets the HTTP method to use. By default it's set to POST.
145
+ *
150
146
* @param method new HTTP method to use
151
147
*/
152
148
public void setMethod (final String method ) {
@@ -156,6 +152,7 @@ public void setMethod(final String method) {
156
152
157
153
/**
158
154
* Gets the HTTP method to use.
155
+ *
159
156
* @return
160
157
*/
161
158
protected String getMethod () {
@@ -164,6 +161,7 @@ protected String getMethod() {
164
161
165
162
/**
166
163
* Gets the upload ID of this request.
164
+ *
167
165
* @return
168
166
*/
169
167
protected String getUploadId () {
@@ -172,6 +170,7 @@ protected String getUploadId() {
172
170
173
171
/**
174
172
* Gets the URL of the server side script that will handle the multipart form upload.
173
+ *
175
174
* @return
176
175
*/
177
176
protected String getServerUrl () {
@@ -180,6 +179,7 @@ protected String getServerUrl() {
180
179
181
180
/**
182
181
* Gets the list of the files that has to be uploaded.
182
+ *
183
183
* @return
184
184
*/
185
185
protected ArrayList <FileToUpload > getFilesToUpload () {
@@ -188,6 +188,7 @@ protected ArrayList<FileToUpload> getFilesToUpload() {
188
188
189
189
/**
190
190
* Gets the list of the headers.
191
+ *
191
192
* @return
192
193
*/
193
194
protected ArrayList <NameValue > getHeaders () {
@@ -196,6 +197,7 @@ protected ArrayList<NameValue> getHeaders() {
196
197
197
198
/**
198
199
* Gets the list of the parameters.
200
+ *
199
201
* @return
200
202
*/
201
203
protected ArrayList <NameValue > getParameters () {
@@ -204,6 +206,7 @@ protected ArrayList<NameValue> getParameters() {
204
206
205
207
/**
206
208
* Gets the upload notification configuration.
209
+ *
207
210
* @return
208
211
*/
209
212
protected UploadNotificationConfig getNotificationConfig () {
@@ -212,6 +215,7 @@ protected UploadNotificationConfig getNotificationConfig() {
212
215
213
216
/**
214
217
* Gets the application context.
218
+ *
215
219
* @return
216
220
*/
217
221
protected Context getContext () {
0 commit comments