Skip to content
Back

[SOLVED] storage.getFileDownload() don't works correctly

  • 1
  • Android
  • Storage
retr122
11 Jul, 2023, 18:24

I write app in Android Java and need to download file from Appwrite Cloud into custom directory. Firstly I need to test how it works, but my code don't downloading file.

TypeScript
  currentQuizFileIdString,
        new Continuation<Object>() {
                                    @NotNull
                                    @Override
                                    public CoroutineContext getContext() {
                                        return EmptyCoroutineContext.INSTANCE;
                                    }

                                    @Override
                                    public void resumeWith(@NotNull Object o) {
                                        String json = "";
                                        try {
                                            if (o instanceof Result.Failure) {
                                                Result.Failure failure = (Result.Failure) o;
                                                throw failure.exception;
                                            } else {
                                                runOnUiThread(new Runnable() {
                                                    public void run() {
                                                        Toast toast = Toast.makeText(NetworkQuizActivity.this.getApplicationContext(), getResources().getString(R.string.successQuizDownload), LENGTH_LONG);
                                                        toast.show();
                                                    }
                                                });
                                            }
                                        } catch (Throwable th) {
                                            Log.e("ERROR", th.toString());
                                        }
                                    }
                                }); ```

It returns my custom Toast, but file don't downloaded. Why?
TL;DR
The user was having issues with the `storage.getFileDownload()` function in their Android Java app. They were trying to download a file from Appwrite Cloud into a custom directory, but it was not working. They asked for help and shared their code. Someone asked why they were not doing anything with the downloaded file (the `Object o`) and suggested it might be the issue. The user confirmed that they were trying to download the file, not create it. It seems that the issue was resolved, but the solution is not mentioned in the thread.
Drake
11 Jul, 2023, 23:17

What makes you say the file didn't get downloaded? Also, looking at your code, it doesn't look like you're doing anything with the downloaded file (the Object o)

retr122
12 Jul, 2023, 02:57

What is Object o in this case?

retr122
12 Jul, 2023, 02:57

This is io.appwrite.models.File?

Drake
12 Jul, 2023, 03:01

No, it should be the bytes

retr122
12 Jul, 2023, 03:01

And then i would be create file with these bytes?

Drake
12 Jul, 2023, 03:02

Sure

retr122
12 Jul, 2023, 03:06

I'll try it and feedback later

retr122
12 Jul, 2023, 05:34

Thanks! It working!

retr122
12 Jul, 2023, 05:34

[SOLVED] storage.getFileDownload() don't works correctly

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more