import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;
import com.owncloud.android.lib.resources.files.UploadRemoteFileOperation;
import com.owncloud.android.utils.FileStorageUtils;
+import com.owncloud.android.utils.UriUtils;
/**
private static final String TAG = UploadFileOperation.class.getSimpleName();
- private static final String URI_CONTENT_SCHEME = "content://";
- private static final String MIME_TYPE_PDF = "application/pdf";
- private static final String FILE_EXTENSION_PDF = ".pdf";
-
private Account mAccount;
private OCFile mFile;
private OCFile mOldFile;
private String mOriginalStoragePath = null;
PutMethod mPutMethod = null;
private Set<OnDatatransferProgressListener> mDataTransferListeners = new HashSet<OnDatatransferProgressListener>();
- private final AtomicBoolean mCancellationRequested = new AtomicBoolean(false);
+ private AtomicBoolean mCancellationRequested = new AtomicBoolean(false);
private Context mContext;
private UploadRemoteFileOperation mUploadOperation;
} else {
String temporalPath = FileStorageUtils.getTemporalPath(mAccount.name) + mFile.getRemotePath();
-
- if (isPdfFileFromContentProviderWithoutExtension()){
- temporalPath += FILE_EXTENSION_PDF;
- mFile.setRemotePath(mFile.getRemotePath() + FILE_EXTENSION_PDF);
- }
-
mFile.setStoragePath(temporalPath);
temporalFile = new File(temporalPath);
try {
// In case document provider schema as 'content://'
- if (mOriginalStoragePath.startsWith(URI_CONTENT_SCHEME)) {
+ if (mOriginalStoragePath.startsWith(UriUtils.URI_CONTENT_SCHEME)) {
Uri uri = Uri.parse(mOriginalStoragePath);
* Checks if remotePath does not exist in the server and returns it, or adds
* a suffix to it in order to avoid the server file is overwritten.
*
- * @param string
+ * @param wc
+ * @param remotePath
* @return
*/
private String getAvailableRemotePath(OwnCloudClient wc, String remotePath) throws Exception {
}
public void cancel() {
- mUploadOperation.cancel();
- }
-
- /**
- * Checks if content provider, using the content:// scheme, returns a file with mime-type
- * 'application/pdf' but file has not extension
- * @return true if is needed to add the pdf file extension to the file
- */
- private boolean isPdfFileFromContentProviderWithoutExtension() {
- return mOriginalStoragePath.startsWith(URI_CONTENT_SCHEME) &&
- mFile.getMimetype().equals(MIME_TYPE_PDF) &&
- !mFile.getFileName().endsWith(FILE_EXTENSION_PDF);
+ mCancellationRequested = new AtomicBoolean(true);
+ if (mUploadOperation != null) {
+ mUploadOperation.cancel();
+ }
}
}