Compare commits

...
Author SHA1 Message Date
tobiasKaminsky f196c5f593 wip
Signed-off-by: tobiasKaminsky <[email protected]>
2020-06-04 12:38:42 +02:00
tobiasKaminsky cf3d1e2632 wip
Signed-off-by: tobiasKaminsky <[email protected]>
2020-06-04 12:24:05 +02:00
4 changed files with 22 additions and 0 deletions

No files matched your search

@@ -924,6 +924,8 @@ public class FileUploader extends Service
intent.putExtra(FileUploader.KEY_WHILE_CHARGING_ONLY, requiresCharging);
intent.putExtra(FileUploader.KEY_NAME_COLLISION_POLICY, nameCollisionPolicy);
Log_OC.d("ExternalUpload", "upload file: " + localPaths[0]);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context.startForegroundService(intent);
} else {
@@ -38,6 +38,7 @@ import android.content.res.ColorStateList;
import android.content.res.Resources.NotFoundException;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@@ -92,6 +93,7 @@ import com.owncloud.android.utils.ErrorMessageAdapter;
import com.owncloud.android.utils.FileSortOrder;
import com.owncloud.android.utils.MimeType;
import com.owncloud.android.utils.ThemeUtils;
import com.owncloud.android.utils.UriUtils;
import java.io.File;
import java.io.FileWriter;
@@ -859,6 +861,18 @@ public class ReceiveExternalFilesActivity extends FileActivity
mStreamsToUpload = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
}
if (mStreamsToUpload != null) {
Log_OC.d("ExternalUpload", "Received: " + mStreamsToUpload.size());
for (Parcelable parcelable : mStreamsToUpload) {
if (parcelable instanceof Uri) {
Log_OC.d("ExternalUpload", "URI: " + UriUtils.getDisplayNameForUri((Uri) parcelable, this));
} else {
Log_OC.d("ExternalUpload", "no URI: " + parcelable.toString());
}
}
}
if (mStreamsToUpload == null || mStreamsToUpload.isEmpty() || mStreamsToUpload.get(0) == null) {
mStreamsToUpload = null;
saveTextsFromIntent(intent);
@@ -143,6 +143,8 @@ public class CopyAndUploadContentUrisTask extends AsyncTask<Object, Void, Result
currentUri = uris[i];
currentRemotePath = remotePaths[i];
Log_OC.d("ExternalUpload", "copy file: " + currentUri);
fullTempPath = FileStorageUtils.getTemporalPath(account.name) + currentRemotePath;
inputStream = leakedContentResolver.openInputStream(currentUri);
File cacheFile = new File(fullTempPath);
@@ -110,9 +110,11 @@ public class UriUploader {
if (ContentResolver.SCHEME_CONTENT.equals(sourceUri.getScheme())) {
contentUris.add(sourceUri);
contentRemotePaths.add(remotePath);
Log_OC.d("ExternalUpload", "upload as content uri: " + sourceUri.getPath());
} else if (ContentResolver.SCHEME_FILE.equals(sourceUri.getScheme())) {
/// file: uris should point to a local file, should be safe let FileUploader handle them
Log_OC.d("ExternalUpload", "upload as local file: " + sourceUri.getPath());
requestUpload(sourceUri.getPath(), remotePath);
schemeFileCounter++;
}
@@ -120,11 +122,13 @@ public class UriUploader {
}
if (!contentUris.isEmpty()) {
Log_OC.d("ExternalUpload", "size of contentUri: " + contentUris.size());
/// content: uris will be copied to temporary files before calling {@link FileUploader}
copyThenUpload(contentUris.toArray(new Uri[0]),
contentRemotePaths.toArray(new String[0]));
} else if (schemeFileCounter == 0) {
Log_OC.d("ExternalUpload", "contentUri is empty");
mCode = UriUploaderResultCode.ERROR_NO_FILE_TO_UPLOAD;
}