Chapter 5. Dealing with Files
When you are building a Backbone application you will consume resources from a RESTful web service; however most of the RESTful services use the JSON format to encode information, but JSON is not suitable to send and receive files. How we can send files to a RESTful server?
If you are developing an application that is not JavaScript–intensive, you can send files through an HTML form, but in Single Page Applications (SPA) this is not the best way to do it. Another issue is that Backbone does not provide an easy mechanism to send files because it is not compatible with the RESTful specification.
But web applications need to work with files. There are some approaches to deal with this common issue. For example, you could use a traditional POST form on resources where files may be included; however, that's not a good option. In this chapter you will learn the following:
- Handle file uploads from an Express server
- Adopt strategies to send files...