Encoding the upload file

Another approach to uploading files is to encode the file into base64. When you encode a binary file to base64, the result is a string that we can use as an attribute in the request object.

Though it can be useful to create objects with the file attached in the resource, or to use it as another resource in the server, this is not a recommended approach. This approach has some limitations:

  • If the backend server is a node, the thread will be locked until the server decodes the base64 string. This will lead to a low-performance app.
  • You cannot upload large amounts of data.
  • If the file is large, the Backbone application will freeze until the file is encoded to base64.

If you are uploading very small amounts of data and don't have ...

Get Mastering Backbone.js now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.