+ /// check location of local file, and copy to a temporal file to upload it if not in its corresponding directory
+ String targetLocalPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, mFile);
+ if (!originalStoragePath.equals(targetLocalPath)) {
+ File ocLocalFolder = new File(FileStorageUtils.getSavePath(mAccount.name));
+ originalFile = new File(originalStoragePath);
+ if (!mMoveLocalFile) {
+ // the file must be copied to the ownCloud local folder
+
+ if (ocLocalFolder.getUsableSpace() < originalFile.length()) {
+ result = new RemoteOperationResult(ResultCode.LOCAL_STORAGE_FULL);
+ return result;
+
+ } else {
+ String temporalPath = FileStorageUtils.getTemporalPath(mAccount.name) + mFile.getRemotePath();
+ mFile.setStoragePath(temporalPath);
+ temporalFile = new File(temporalPath);
+ if (!originalStoragePath.equals(temporalPath)) { // preventing weird but possible situation
+ InputStream in = new FileInputStream(originalFile);
+ OutputStream out = new FileOutputStream(temporalFile);
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = in.read(buf)) > 0){
+ out.write(buf, 0, len);
+ }
+ in.close();
+ out.close();
+ }
+ }
+ } // else - the file will be MOVED to the corresponding directory AFTER the upload finishes
+ }
+ localCopyPassed = true;
+