android icon indicating copy to clipboard operation
android copied to clipboard

[BUG] Text (.txt) file won't download / open in Android App

Open geobzmm opened this issue 1 year ago • 58 comments

Actual behaviour

Creating a .txt file on another device containing a few words or some notes in a accessible folder then syncs as expected to all devices - server, laptop, desktop and Mobile / Cell. the .txt file can be opened / viewed on server, laptop (win 10), desktop (win 11) but Android App displays message "Download Failed". All other "document" formats appear to work fine (eg. .pdf, .docx, .xlsx, .doc etc...).

Expected behaviour

The .txt file should open and show the text in the file or be downloadable to the Android device (neither of which is possible).

Steps to reproduce

  1. Create .txt file containing text such as "Hello World!".
  2. Allow to sync to OwnCloud Server - this works when file is originally generated on PC.
  3. Refresh folder on Android device and attempt to open / download file.
  4. Message appears onscreen "Download Failed".

Can this problem be reproduced with the official owncloud server? (url: https://demo.owncloud.org, user: test, password: test) Not tested on Official Server

Environment data

Android version: v13

Device model: Samsung Galaxy S20+5G

Stock or customized system: Stock One UI v5.1

ownCloud app version: v4.2.1

ownCloud server version: Infinite Scale Community v4.0.3 running webclient v7.1.2

Logs

ownCloud App Log (data/owncloud.log)

D: 2024-03-27 20:28:32:819(SingleSessionManager.java:98)getClientFor starting 
V: 2024-03-27 20:28:32:819(SingleSessionManager.java:125)reusing client for account [OwnCloudServer]
D: 2024-03-27 20:28:32:820(SingleSessionManager.java:180)getClientFor finishing 
D: 2024-03-27 20:28:32:869(OwnCloudClient.java:129)Executing in request with id ff931731-xxx-etc
I: 2024-03-27 20:28:32:869(ReadRemoteFileOperation.kt:72)Read remote file /Basic Files/Another Text File.txt with status 207
I: 2024-03-27 20:28:32:871(SynchronizeFileUseCase.kt:66)File Another Text File.txt is not downloaded. Let's download it
I: 2024-03-27 20:28:32:875(DownloadFileUseCase.kt:103)Download of Another Text File.txt has been enqueued.
D: 2024-03-27 20:28:32:876(ViewModelExt.kt:68)Use case executed: SynchronizeFileUseCase with result: Success(data=DownloadEnqueued(workerId=d04d033c-xxxx-4833-b2c2-xxx))
D: 2024-03-27 20:28:32:912(GetRemoteAppRegistryOperation.kt:54)Successful response {"mime-types":[]}
D: 2024-03-27 20:28:32:917(GetRemoteAppRegistryOperation.kt:64)Get AppRegistry completed and parsed to AppRegistryResponse(value=[])
D: 2024-03-27 20:28:32:962(SingleSessionManager.java:98)getClientFor starting 
V: 2024-03-27 20:28:32:963(SingleSessionManager.java:125)reusing client for account [OwnCloudServer]
D: 2024-03-27 20:28:32:964(SingleSessionManager.java:180)getClientFor finishing 
D: 2024-03-27 20:28:32:965(OwnCloudClient.java:129)Executing in request with id dc4b9aca-xxxx-4dbb-a919-xxx
D: 2024-03-27 20:28:33:073(OwnCloudClient.java:129)Executing in request with id eb935ee4-xxxx-4178-8530-xxx
E: 2024-03-27 20:28:33:228(DownloadRemoteFileOperation.kt:154)Content-Length not equal to transferred bytes.
D: 2024-03-27 20:28:33:229(DownloadRemoteFileOperation.kt:155)totalToTransfer = 0, transferred = 2451
I: 2024-03-27 20:28:33:231(DownloadRemoteFileOperation.kt:80)Download of /Basic Files/Another Text File.txt to /data/user/0/com.owncloud.android/files/owncloud/tmp/[OwnCloudServer]/80630633-xxxx-4b45-a280-bd1e9c8d8eec$b22ee417-b5ce-xxxx-920e-xxxx/Basic Files/Another Text File.txt - HTTP status code: 207
E: 2024-03-27 20:28:33:236(DownloadFileWorker.kt:127)com.owncloud.android.domain.exceptions.LocalStorageNotMovedException
	at com.owncloud.android.workers.DownloadFileWorker.moveTemporalFileToFinalLocation(DownloadFileWorker.kt:200)
	at com.owncloud.android.workers.DownloadFileWorker.doWork(DownloadFileWorker.kt:123)
	at androidx.work.CoroutineWorker$startWork$1.invokeSuspend(CoroutineWorker.kt:68)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)

geobzmm avatar Mar 27 '24 20:03 geobzmm

Hi @geobzmm! Thanks a lot for the info! We'll take a look ASAP and will let you know news about this in this thread 🍻

JuancaG05 avatar Apr 01 '24 06:04 JuancaG05

I have the exact same problem with four different devices and v4.2.1 (I downgraded one to v4.2.0, but this did not make a difference), but with all tested data types (*.ogg, *.txt, *.jpg)

D: 2024-04-20 01:13:34:511(OwnCloudClient.java:129)Executing in request with id 76fe8527-57eb-4255-bdbe-cfcb14c67f72
E: 2024-04-20 01:13:35:911(DownloadRemoteFileOperation.kt:154)Content-Length not equal to transferred bytes.
D: 2024-04-20 01:13:35:913(DownloadRemoteFileOperation.kt:155)totalToTransfer = 0, transferred = 3198389
I: 2024-04-20 01:13:35:919(DownloadRemoteFileOperation.kt:80)Download of /testfile.ogg to /data/user/0/com.owncloud.android/files/owncloud/tmp/xxx@xxx/testfile.ogg - HTTP status code: 207
E: 2024-04-20 01:13:35:921(DownloadFileWorker.kt:127)com.owncloud.android.domain.exceptions.LocalStorageNotMovedException
        at com.owncloud.android.workers.DownloadFileWorker.moveTemporalFileToFinalLocation(DownloadFileWorker.kt:200)
        at com.owncloud.android.workers.DownloadFileWorker.doWork(DownloadFileWorker.kt:123)
        at androidx.work.CoroutineWorker$startWork$1.invokeSuspend(CoroutineWorker.kt:68)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)

Webfrontend and Desktop-Sync are working fine.

This makes the Owncloud-App completely unusable for me.

chaotix- avatar Apr 19 '24 23:04 chaotix-

will do a look here. Meanwhile, you can use the "open with" option to open with 3rd party apps (changes will sync to the server as well)

jesmrec avatar Apr 24 '24 06:04 jesmrec

Thank you for taking your time to look at this.

Unfortunately using "open with" does not work either. I get the same small popup "Herunterladen fehlgeschlagen" (Download failed) at the bottom of the screen before it asks what app I want to open the file with.

Let me know if I can assist you in any way with debugging this.

chaotix- avatar Apr 24 '24 10:04 chaotix-

Hello, Same probleme for me: I: 2024-04-29 08:38:47:680(DownloadRemoteFileOperation.kt:80)Download of /test.pdf to /data/user/0/com.owncloud.android/files/owncloud/tmp/xxx@xxxx/test.pdf - HTTP status code: 207 E: 2024-04-29 08:38:47:682(DownloadFileWorker.kt:127)com.owncloud.android.domain.exceptions.LocalStorageNotMovedException

No way to access to my files

Everything is working on the PC or web client. Uninstall / install does not change anything

Thks for you help

Noni006 avatar Apr 29 '24 07:04 Noni006

After lot of tests, I found the solution (in my case) The problem came from php-fpm With this processor, my owncloud server response as Transfer-Encoding : chunked so without Content-Length

But with apache php: serveur responce is with a Content-Length header and Android client works! A don't kown when it has changed..

Noni006 avatar May 01 '24 12:05 Noni006

@chaotix- @geobzmm could you take a look to @Noni006's solution? ⬆️ ⬆️ . It might fit your case as well.

jesmrec avatar May 02 '24 06:05 jesmrec

@jesmrec Unfortunately this is not a solution for me as I am running several different virtual servers that need to run under different users. I don't think this is configurable with mod_php so I need to use php-fpm.

chaotix- avatar May 02 '24 09:05 chaotix-

This could be related: https://central.owncloud.org/t/download-failed-unknown-error/47935 Will research a bit about this and see if the problem is a common one for all cases 🚀

JuancaG05 avatar May 03 '24 10:05 JuancaG05

That is my post over at ownCloud Central. I can confirm that the files I tested were text files (markdown, specifically).

I also have been using PHP-FPM with my ownCloud instance for many years and cannot substitute mod PHP.

linkp avatar May 03 '24 13:05 linkp

@linkp @chaotix- @geobzmm I also use only php-fpm instances and had the same problem. by adding the line SetEnv ap_trust_cgilike_cl to the .htaccess file, my problem was solved.

dapkdapk avatar May 04 '24 22:05 dapkdapk

Might worth to mention that OP is using / running:

ownCloud server version: Infinite Scale Community v4.0.3

but other users mention php-fpm bot oCIS doesn't use PHP so this could be something different or even independent from the underlying server variant (oCIS vs. ownCloud 10).

Also not even sure if using php-fpm is officially supported for the PHP variant of ownCloud.

iasdeoupxe avatar May 05 '24 18:05 iasdeoupxe

@linkp @chaotix- @geobzmm I also use only php-fpm instances and had the same problem. by adding the line SetEnv ap_trust_cgilike_cl to the .htaccess file, my problem was solved.

This worked for me as well

JohnHardline avatar May 06 '24 15:05 JohnHardline

It works for me as well. But I had to put it in the .htaccess file in my owncloud-data folder as it is not a subfolder of the owncloud folder.

chaotix- avatar May 06 '24 15:05 chaotix-

Hey @chaotix- , @JohnHardline, @iasdeoupxe, @dapkdapk, @Noni006 glad you found a solution, that seems to be server-related. Could you tell us which server version are you using? So that we can locate the error more easily and maybe solve whatever we need to solve from our side if needed

JuancaG05 avatar May 07 '24 06:05 JuancaG05

@DeepDiver1975 all these problems seem to be related with an incorrect received Content-Length, are you aware of something changing in this regard recently?

JuancaG05 avatar May 07 '24 08:05 JuancaG05

Side note: php-fpm is NOT supported with OC10. You're on your own. You can use a docker environment to setup ownCloud using the official docker image in an isolated way so it doesn't disturb the rest of your installation.

As for oCIS, please try to upgrade to 5.0.3 because it might be fixed there. It could be a server-side issue.

jvillafanez avatar May 07 '24 09:05 jvillafanez

Hey @chaotix- , @JohnHardline, @iasdeoupxe, @dapkdapk, @Noni006 glad you found a solution, that seems to be server-related. Could you tell us which server version are you using? So that we can locate the error more easily and maybe solve whatever we need to solve from our side if needed

Hi @JuancaG05 , this is my owncloud server version and php info lines below. Hope that helps.

version: 10.14.0.3
edition: Community
PHP Version 7.4.33
System	Linux dd29232 5.4.0-174-generic #193-Ubuntu SMP Thu Mar 7 14:29:28 UTC 2024 x86_64
Build Date	Apr 15 2024 11:22:17
Server API	FPM/FastCGI

dapkdapk avatar May 07 '24 12:05 dapkdapk

IF the users running the PHP version of ownCloud are really having the same problem as the OP using the non-PHP OCIS then it is really surprising how this should be a server side issue if two completely different technologies suddenly causing the very same issue and one requires an update (OCIS) while the other requires server side modifications in the PHP configuration (OC 10).

Sounds more that something changed on the client side (be it in the app itself, in a library or in Android).

iasdeoupxe avatar May 07 '24 19:05 iasdeoupxe

Just wanted to add that since about a week's time I was facing the same problem (all filetypes affected, on multiple android phones) and adding the SetEnv to the (main) .htaccess file solved the issue.

NoSilentRunning avatar May 07 '24 21:05 NoSilentRunning

Just wanted to add that since about a week's time I was facing the same problem (all filetypes affected, on multiple android phones) and adding the SetEnv to the (main) .htaccess file solved the issue.

i get your point and this is also surprising for us. Last app version is two months ago, and server version the same. No changes in last week or last three weeks. Keep checking...

jesmrec avatar May 08 '24 06:05 jesmrec

@iasdeoupxe the common problem is that the server isn't sending the content-length header, or it sends it with a 0 length.

For OC10, as far as I know, the issue happens only with php-fpm, which, as said, it isn't supported. PHP as apache module (I think it's apache prefork) works fine (https://github.com/owncloud/android/issues/4352#issuecomment-2088392337)

For oCIS, the client logs show the same issue: content-length header seems to be 0 for a 207 HTTP response. I don't know the conditions for the server to send that kind of response, but there have been changes in this regard, so it's possible that the issue is solved in recent oCIS versions.

As for the android app, it has problems if the content-length of the downloaded file doesn't match the actual content. If the code didn't change, either the problem was there the whole time but nobody hit it, or android changed something about how downloads are handled if there is a mismatch with the content-length.

jvillafanez avatar May 08 '24 07:05 jvillafanez

In addition, I'd recommend to anyone having this issue (and posting here) to provide the environment data (check the opening post). The issue was posted for an android v13 phone, which is a relatively recent version. If everyone is having the issue with that version, we could narrow down the problem.

jvillafanez avatar May 08 '24 07:05 jvillafanez

I have the same problem. I can upload files and see the files. But when trying to open them or download them I get unknown error while downloading. Filetype does not matter.

Specs:

Android 14 Samsung OneUI 6.0 Owncloud Android app 4.2.1

Server: Ocis 5.0.3

Logs:

2024-05-08T11:32:53Z WRN http |
service=storage-system pkg=rhttp 
traceid=############### host=127.0.0.1 
method=GET uri=/data/spaces/
jsoncs3-share-manager-metadata%21jsoncs3-share
-manager-metadata/groups/
########-###--####-####-############/
received.json url=/groups/
########-####-####-####-############/
received.json proto=HTTP/1.1 status=404 size=0 
start=08/May/2024:11:32:53 +0000 end=08/May/
2024:11:32:53 +0000 time_ns=154780 
line=github.com/cs3org/reva/[email protected]/internal
/http/interceptors/log/log.go:112 

appiekap653 avatar May 08 '24 11:05 appiekap653

@appiekap653 did you notice the error recently? did you update the app?

jesmrec avatar May 08 '24 12:05 jesmrec

@appiekap653 did you notice the error recently? did you update the app?

I just installed owncloud for the first time yesterday. So this is the first time I tried everything and came on this error.

appiekap653 avatar May 08 '24 12:05 appiekap653

I just checked if downloading the same file was working with the web-client and that worked without problems.

Maybe I must also mention that the file was uploaded with the automatic photo upload function of the android app to a folder in a space.

appiekap653 avatar May 08 '24 12:05 appiekap653

did you try to download a file in test server (ocis.owncloud.works)?

jesmrec avatar May 08 '24 12:05 jesmrec

did you try to download a file in test server (ocis.owncloud.works)?

No, what are the credentials?

appiekap653 avatar May 08 '24 12:05 appiekap653

einstein/relativity

jesmrec avatar May 08 '24 12:05 jesmrec