47
devTea
6y

So lately I’ve been sending an http request with ajax instead of using classic form submit. Pdf and images need to be converted into byte64 string then send it to the backend, problem is if the size gets too big chrome crashes and showed me ‘Aw snap’, but it works on firefox. Thr file is size could be 3 to 100 mb (for pdf). So my question; is this my problem or just browser limitation?

Comments
  • 1
    As I know there's no limitation on uploading a file through ajax request, if there was you won't be able to done with Firefox as you mentioned. Maybe it's a browser issue.

    PS: you can set limitation in ajax request.
  • 5
    @const last time I checked it is set on backend web config with http request size. Since this is a browser problem should I stick to classic form submission or find another way with ajax? (Does splitting the string into arrays help?)
  • 1
    Did you try also with other browsers?
  • 5
    @dontbeevil only tried on firefox and it worked, the I thought this is probably chrome problem. Is there no one posting data with ajax nowadays?
  • 2
    @devTea classic form submission for large file is not good idea in my opinion, as @dontbeevil said try with different browsers like opera, edge or Vivaldi or even chromium.

    I use Ajax to post data depending upon project.
  • 2
    Splitting should work, but needs some modification to backend as it needs to build the full string upon multiple requests.
  • 4
    @const then how does those cloud storage file upload works? How you handle large file upload on your project?

    @Forside yeah it was during a pas project I’m just curious what I should do if I face another one like this
  • 1
    @devTea unfortunately I still not done a project yet dealing with large upload and download. But I believe they use RestAPI to transfer data, they store data in chunk of file or as single file depending upon server code. And large data transmission over ajax is not an issue.
    I'll give time on this seems interesting to me.
  • 2
    Try to look into multipart/form-data upload, AWS is doing so:
    https://docs.aws.amazon.com/AmazonS...
  • 3
    @theKarlisK testing it on chromium? Not yet
    @Minion ok
  • 3
    @theKarlisK I’ve read that it’s a bug since long time ago, how you deal with large uploads?
  • 3
    @theKarlisK never head of gzip, thanks will look at it later
  • 1
    In my localhost file uploader big files loading normal.
  • 3
    @Pogromist did you use plugin for file upload or vanilla filereader from js?
  • 1
    @devTea used File object as argument to XMLHttpRequest.send(file) to send single file. And upload event to determine upload percent, that's all.
  • 3
    @Pogromist ok will try that if I have time (sorry if this is obvious but did you turn it into base64 and send it in string format?)
  • 1
    @devTea binary data.
Add Comment