Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload failed: could not be copied to owncloud local directory #101

Closed
pascalBokBok opened this issue Mar 5, 2013 · 36 comments
Closed

Upload failed: could not be copied to owncloud local directory #101

pascalBokBok opened this issue Mar 5, 2013 · 36 comments

Comments

@pascalBokBok
Copy link

I cannot upload files.
It may be because my phone's internal memory does not have so much space left. But 14MB should be enough for a photo.
My SD card has lots of space.

@davivel
Copy link
Contributor

davivel commented Mar 6, 2013

Could you tell us what model is your device?

@pascalBokBok
Copy link
Author

HTC Desire (the original)

@untitaker
Copy link

I've experienced the sdcard fs being remounted as read-only sometimes with my old Wildfire. Can other applications write to the sdcard just fine?

@pascalBokBok
Copy link
Author

No problems with sdcard. besides that is where the pictures I want to upload are located :-)

@davivel
Copy link
Contributor

davivel commented Mar 7, 2013

Could you download files with the ownCloud app? Please, check if they are located into the 'ownCloud' directory in your SD Card.

@pascalBokBok
Copy link
Author

No problem downloading, just pulled down a 5MB high-res picture on the phone.
I mounted the phone's SD card on the computer through USB to see that indeed the picture was downloaded into the owncloud/[myaccount]/[mypath].
Still can't upload. I get a owncloud message in the system bar "Upload failed: could not be copied to owncloud local directory"

@davivel
Copy link
Contributor

davivel commented Mar 7, 2013

Does the fail occur always, or just when the device is connected to the computer through USB?

How much space do you have free in the SD card?

@pascalBokBok
Copy link
Author

I did obviously not try with the device connected as there would be no access to the SDcard.
2GB free

@davivel
Copy link
Contributor

davivel commented Mar 7, 2013

Sorry, I did not mean to be patronizing. Some times obvious things are not so obvious for everybody.

Could you tell me what is the version of Android in your device, and if it stock or customized? It can be a problem with the method used to ask for the remaining space in disk.

@pascalBokBok
Copy link
Author

No problem.
I have Android 2.2.2.

@bigmarinz
Copy link

same problem here.
Motorola pro, android 2.2.2

@pascalBokBok
Copy link
Author

Any news on this?

@davivel
Copy link
Contributor

davivel commented Mar 13, 2013

Sorry, not yet. We tried to reproduce it with some 2.2 devices, but seems it is something more specific.

We are very busy with some other improvements right now. Probably we will not be able to work in this until the end of the week.

@pascalBokBok
Copy link
Author

I succeded in uploading files when accepting to move the file to the owncloud folder.
(Open owncloud app -> menu button -> upload -> files -> select some file -> upload -> Accept move instead of copy)
Thus it seems to be something with checking amount of diskspace available.

@davivel
Copy link
Contributor

davivel commented Mar 14, 2013

Yes, we think it is a problem with the implementation of the class http://developer.android.com/reference/android/os/StatFs.html in some devices. We use it in Android 2.2 systems because this http://developer.android.com/reference/java/io/File.html#getUsableSpace() is available only from Android 2.3.

The most anoying part is that StatFs is working fine in our 2.2 test devices...

@pascalBokBok
Copy link
Author

So what to do?
I'm not experiencing this with other programs, there must another method that works.

@pascalBokBok
Copy link
Author

ping :-)

@pascalBokBok
Copy link
Author

And suddenly it works after having wiped my Owncloud server and reinstalled 4.8... Was an update rolled out?

@pascalBokBok
Copy link
Author

The instant upload of pictures taken with the camera does still not work. should I file a seperate report?

@pascalBokBok
Copy link
Author

The version of owncloud I had reinstalled was 4.5.8 not 4.8

@davivel
Copy link
Contributor

davivel commented Apr 9, 2013

@pascalBokBok , sorry for the lack of responsiveness.

I am very happy to read that you can upload, because we found no way to reproduce this in our 2.2 devices, or in emulators.

About the instant uploads issue, it is something different and well known. It is already reported here : #6 . It is probable that we finally solve it really soon.

@bigmarinz, could you tell us if this problem is still alive for you?

@davivel
Copy link
Contributor

davivel commented Apr 17, 2013

Seems the main problem is inactive now. Pending problems are in other issues, such as #6 .

@davivel davivel closed this as completed Apr 17, 2013
@jksinton
Copy link

I'm getting this problem on Moto X, Android Version 4.4. When I try to upload a file from the phone's "Downloads," this error is produced in the notification bar.

In other words, I go to the Downloads app. Then, I long hold a file I wish to upload to bring up the share icon. I press the share icon and choose ownCloud, and finally choose a directory on my ownCloud drive. It won't upload the file.

OC server is OC 8.0.1 on Ubuntu.

I can successfully upload a file from the Google Drive app to ownCloud. Also, I was able to make a new folder.

@jksinton
Copy link

I've reproduced this issue in Android Studio on an emulated device running android-19.

@tobiasKaminsky
Copy link
Contributor

You are right.
But the problem seems to be limited only to the download app.

@jksinton
Copy link

For some reason, the download app Intent object is passing the wrong path to the local file:

public int onStartCommand(Intent intent, int flags, int startId) {
...
} else { // mUploadType == UPLOAD_MULTIPLE_FILES
...
localPaths = new String[] { intent.getStringExtra(KEY_LOCAL_FILE) };
...
I added a Log_OC.d to view the contents of localPath in obtainNewOCFileToUpload(String remotePath, String localPath, String mimeType, FileDataStorageManager storageManager)

At least this is what I have been able to uncover from one night of debugging.

Regards,
James

@jksinton
Copy link

It seems the bug is actually in uploadFiles() from Uploader.java.

For a PDF, Uri.decode(uri.toString()) does not actually provide the localPath to the file. Also, for an Image file, i.e. mimeType.contains("image"), the columns projection do not match for the URI: content://com.android.providers.downloads.documents/document/. Thus, ownCloud crashes when trying to upload an image from the Downloads app, because localPath ends up being null in obtainNewOCFileToUpload from FileUploader.java.

I added some logging statements while trying to upload a pdf file:

Log_OC.d(TAG, "uri scheme is " + uri.getScheme());
String mimeType = getContentResolver().getType(uri);
Log_OC.d(TAG, "mime type is " + mimeType);

These printed:

uri scheme is content
mime type is application/pdf

I added this code to the else statement that catches content that is not an Image, Audio, nor Video:

Log_OC.d(TAG, "uri.getPath() is " + uri.getPath());
Log_OC.d(TAG, "uri.toString() is " + uri.toString());
Log_OC.d(TAG, "Uri.decode(uri.toString()) is " + Uri.decode(uri.toString()));

Cursor c = getContentResolver().query(uri, null, null, null, null);
c.moveToFirst();
for(int col=0; col < c.getColumnCount(); col++) {
    String colName = c.getColumnName(col);
    Log_OC.d(TAG,"ColumnName for col " + Integer.toString(col) + " is "  + colName);
    Log_OC.d(TAG,"getString for col " + Integer.toString(col) + " is "  + c.getString(col));
}

This was the output:

uri.getPath() is /document/7912
uri.toString() is content://com.android.providers.downloads.documents/document/7912
Uri.decode(uri.toString()) is content://com.android.providers.downloads.documents/document/7912

ColumnName for col 0 is document_id
getString for col 0 is 7912
ColumnName for col 1 is mime_type
getString for col 1 is application/pdf
ColumnName for col 2 is _display_name
getString for col 2 is NRG Stadium Houston - NRG Stadium Tickets Available from OnlineCityTickets.com.pdf
ColumnName for col 3 is summary
getString for col 3 is NRG Stadium Houston - NRG Stadium Tickets Available from OnlineCityTickets.com.pdf
ColumnName for col 4 is last_modified
getString for col 4 is 1428751149040
ColumnName for col 5 is flags
getString for col 5 is 6
ColumnName for col 6 is _size
getString for col 6 is 161873

@jksinton
Copy link

This works to upload a file from the downloads app by changing the else statement that catches content that is not an Image, Audio, nor Video:

String filePath = "";
String id = DocumentsContract.getDocumentId(uri);
Uri contentUri = ContentUris.withAppendedId( Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));

Cursor cursor = null;
String column = "_data";
String[] projection = { column };
cursor = getContentResolver().query(contentUri, projection, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
    final int index = cursor.getColumnIndexOrThrow(column);
    filePath = cursor.getString(index);
}

See jksinton@1ba1dfe

This uses some of the Storage Access Framework taught by Paul Burke at http://stackoverflow.com/questions/19834842/android-gallery-on-kitkat-returns-different-uri-for-intent-action-get-content

Mr. Burke commented that a more up-to-date version is here:
https://github.com/iPaulPro/aFileChooser/blob/master/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java

This works to upload content that is not an image, video, or audio file, e.g. a word doc or a pdf. We may need to add similar if-else statements that determine if the file is from the downloads app, e.g.:

else if (isDownloadsDocument(uri)) {

using this:

public static boolean isDownloadsDocument(Uri uri) {
    return "com.android.providers.downloads.documents".equals(uri.getAuthority());
}

If we want to upload an image, video, or audio from the download app.

@davivel
Copy link
Contributor

davivel commented Apr 24, 2015

Thanks for all your work, @jksinton . So. this seems directly related to #296 and #709. Need to check it.

@enoch85
Copy link
Member

enoch85 commented Mar 17, 2016

Is this still valid?

@jksinton
Copy link

Looks like the if else branch for an image, video, audio is incorporated in Uploader.java. I just tested an image and pdf file. They uploaded. We can probably close this issue.

@enoch85
Copy link
Member

enoch85 commented Mar 17, 2016

cc @davivel Please close. @ALL Feel free to reopen if this issue still presists.

@davivel
Copy link
Contributor

davivel commented Mar 21, 2016

Unfortunately, this is strongly related to #1515, and there is something wrong there.

@jksinton , what version of the app did you use for your last test? Could you try again with a *.zip or *.apk file instead of PDF?

@jksinton
Copy link

I'm using v. 1.9.1 with server 8.2.2 stable. I was able to upload zip and apk files from the downloads app.

@tobiasKaminsky
Copy link
Contributor

@jksinton is this still a problem?

@hodyroff
Copy link

hodyroff commented Dec 9, 2016

No reaction, closing. Please comment/reopen when you have information including newest version feedback. Thanks!

@hodyroff hodyroff closed this as completed Dec 9, 2016
davigonz pushed a commit that referenced this issue Feb 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants