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

OutOfMemoryError when uploading file #564

Closed
franciscoaguirre opened this issue Dec 21, 2018 · 6 comments
Closed

OutOfMemoryError when uploading file #564

franciscoaguirre opened this issue Dec 21, 2018 · 6 comments
Assignees
Labels
🐛 bug Something isn't working
Milestone

Comments

@franciscoaguirre
Copy link

Hi everyone!

I am trying to upload a video in android using Fuel.
Everything works fine for small videos but for large ones I get an OutOfMemoryError.
The upload appears to happen until a certain point (seen in the progress bar), then the error is thrown and it stops.
I saw a similar issue related to downloading files and tried to fix the error based on it but unfortunately couldn't.

Code:

Fuel.upload("/videos")
        .source { request, url -> videoFile }
        .name { "video" }
        .progress { readBytes, totalBytes ->
            if (totalBytes.toFloat() != 0f) {
                val progress = readBytes.toFloat() / totalBytes.toFloat() * 100
                runOnUiThread { progressBar.progress = progress.toInt() }
            }
        }
        .responseJson { request, response, result ->
            result.fold(
                success = { json -> "Done!" },
                failure = { error -> Log.e("Failure", error.toString()) }
            )
        }

Any help would be gladly appreciated!

@SleeplessByte
Copy link
Collaborator

Hi there,

This should have been fixed, but maybe it's not in the latest release! It's not supposed to retain the file in memory, but there used to be an error with progress + large files. See if the error goes away if you remove the .progress function. If that solves it, you can use that until we release 2.0.0.

@SleeplessByte SleeplessByte added the 🐛 bug Something isn't working label Dec 25, 2018
@SleeplessByte SleeplessByte self-assigned this Dec 25, 2018
@franciscoaguirre
Copy link
Author

franciscoaguirre commented Dec 26, 2018

Taking away the .progress method didn't work unfortunately, the same OutOfMemoryError is thrown.
Do you have any idea when Fuel 2.0.0 will be released?

@SleeplessByte SleeplessByte added this to the Fuel 2.0 milestone Dec 27, 2018
@SleeplessByte
Copy link
Collaborator

My guess it's then how sources are handled in the old code.

https://github.com/kittinunf/Fuel/issues?q=is%3Aopen+is%3Aissue+milestone%3A%22Fuel+2.0%22 only a few more issues left!

@kittinunf
Copy link
Owner

Fuel 2.0 has been released though. @franciscoaguirre Can you see whether this issue can be closed? THanks!

@franciscoaguirre
Copy link
Author

I checked and it works now! Thanks! Closing the issue

@SleeplessByte
Copy link
Collaborator

Thank you for taking the time to check this @franciscoaguirre

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants