In this chapter, we have seen how to upload files to the server; this is not the only way to do it, but is the more extended and flexible approach. Another possible method is to serialize the image into
base64 in the browser, then set the output string as an attribute in the model; when ten models are saved, the file encoded in
base64 will be part of the payload. The server should decode the string and process the result as a file.
We saw how to decouple the view from the business logic. The view should only process DOM events and trigger business logic level events; then a controller can deal with blob objects instead of low-level DOM nodes. This approach helped us to move upload processing from the view to the model, which is the ideal way to do it.
Finally, we dealt with the creation process; we cannot create a resource and attach files at the same time. We should first create the resource and then send all the files to the server as needed.
In the next chapter, you will learn how...