matrix-js-sdk
4794dfc1 - uploadContent: Attempt some consistency between browser and node

Commit
9 years ago
uploadContent: Attempt some consistency between browser and node Previously, the API for uploadContent differed wildly depending on whether you were on a browser with XMLHttpRequest or node.js with the HTTP system library. This lead to great confusion, as well as making it hard to test the browser behaviour. The browser version expected a File, which could be sent straight to XMLHttpRequest, whereas the node.js version expected an object with a `stream` property. Now, we no longer recommend the `stream` property (though maintain it for backwards compatibility) and instead expect the first argument to be the thing to upload. To support the different ways of passing `type` and `name`, they can now either be properties of the first argument (which will probably suit browsers), or passed in as explicit `opts` (which will suit the node.js users). Even more crazily, the browser version returned the value of the `content_uri` property of the result, while the node.js returned the raw JSON. Both flew in the face of the convention of the js-sdk, which is to return the entire parsed result object. Hence, add `rawResponse` and `onlyContentUri` options, which grandfather in those behaviours.
Author
Committer
Parents
Loading