Coder Social home page Coder Social logo

Comments (8)

alexbbb avatar alexbbb commented on May 17, 2024

How large are the files you are trying to upload?

from android-upload-service.

derekentringer avatar derekentringer commented on May 17, 2024

The one that I am testing with right now is 368MB.

from android-upload-service.

derekentringer avatar derekentringer commented on May 17, 2024

Something helpful that I have found and am testing right now is using the setFixedLengthStreamingMode on the httpUrlConnection.

http://developer.android.com/reference/java/net/HttpURLConnection.html

More info...
To upload data to a web server, configure the connection for output using setDoOutput(true).
For best performance, you should call either setFixedLengthStreamingMode(int) when the body length is known in advance, or setChunkedStreamingMode(int) when it is not. Otherwise HttpURLConnection will be forced to buffer the complete request body in memory before it is transmitted, wasting (and possibly exhausting) heap and increasing latency.

from android-upload-service.

alexbbb avatar alexbbb commented on May 17, 2024

Great feedback! So, please try the following temporary patch. If it works I'm going to integrate it in the trunk.
Open UploadService.java and paste the following statement:

conn.setFixedLengthStreamingMode(getTotalBytes(filesToUpload));

right after:

setRequestParameters(requestStream, requestParameters, boundaryBytes);

after that clean and build the library, test it again and tell me if it works for you.

from android-upload-service.

derekentringer avatar derekentringer commented on May 17, 2024

Works :) No more out of memory errors. Thanks for the quick turnaround. Again, great library.

from android-upload-service.

alexbbb avatar alexbbb commented on May 17, 2024

I've read the docs more carefully, and I think the best would be to use

conn.setChunkedStreamingMode(0);

This way there's not the 2GB upload size limit and the best buffer length will be automatically set.

from android-upload-service.

derekentringer avatar derekentringer commented on May 17, 2024

Can confirm that setChunkedStreamingMode(0) also worked well.

from android-upload-service.

alexbbb avatar alexbbb commented on May 17, 2024

Thank you @derekentringer for reporting the issue and for testing the solution, that I just committed: f51a585

Update your working copy and you're good to go ;)

from android-upload-service.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.