+
+ } else if (!intent.hasExtra(KEY_FILE)) {
+ if (localPaths == null) {
+ Log.e(TAG, "Incorrect array for local paths provided in upload intent");
+ return Service.START_NOT_STICKY;
+ }
+ if (remotePaths == null) {
+ Log.e(TAG, "Incorrect array for remote paths provided in upload intent");
+ return Service.START_NOT_STICKY;
+ }
+ if (localPaths.length != remotePaths.length) {
+ Log.e(TAG, "Different number of remote paths and local paths!");
+ return Service.START_NOT_STICKY;
+ }
+
+ files = new OCFile[localPaths.length];
+ for (int i=0; i < localPaths.length; i++) {
+ files[i] = obtainNewOCFileToUpload(remotePaths[i], localPaths[i], ((mimeTypes!=null)?mimeTypes[i]:(String)null), storageManager);
+ }
+ }
+
+ OwnCloudVersion ocv = new OwnCloudVersion(AccountManager.get(this).getUserData(account, AccountAuthenticator.KEY_OC_VERSION));
+ boolean chunked = FileUploader.chunkedUploadIsSupported(ocv);
+ AbstractList<String> requestedUploads = new Vector<String>();
+ String uploadKey = null;
+ UploadFileOperation newUpload = null;
+ try {
+ for (int i=0; i < files.length; i++) {
+ uploadKey = buildRemoteName(account, files[i].getRemotePath());
+ if (chunked) {
+ newUpload = new ChunkedUploadFileOperation(account, files[i], isInstant, forceOverwrite, localAction);
+ } else {
+ newUpload = new UploadFileOperation(account, files[i], isInstant, forceOverwrite, localAction);
+ }
+ if (fixed && i==0) {
+ newUpload.setRemoteFolderToBeCreated();
+ }
+ mPendingUploads.putIfAbsent(uploadKey, newUpload);
+ newUpload.addDatatransferProgressListener(this);
+ requestedUploads.add(uploadKey);
+ }
+
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Not enough information provided in intent: " + e.getMessage());
+ return START_NOT_STICKY;
+
+ } catch (IllegalStateException e) {
+ Log.e(TAG, "Bad information provided in intent: " + e.getMessage());
+ return START_NOT_STICKY;
+
+ } catch (Exception e) {
+ Log.e(TAG, "Unexpected exception while processing upload intent", e);
+ return START_NOT_STICKY;
+