Paw tries to generate the code at best, and doesn't handle all edge cases. Sadly, files/image sending isn't implemented in the code generation for JavaScript... but here's a way to send a file content:
var fileContent = null; // file content comes here
// My API (PUT http://198.11.232.156/oslc/so/triWorkTaskRS/127368846/spi:cstImageIM)
jQuery.ajax({
url: "http://198.11.232.156/oslc/so/triWorkTaskRS/127368846/spi:cstImageIM",
type: "PUT",
headers: {
"Cookie": "JSESSIONID=...",
"Authorization": "Basic ...",
"Content-Type": "image/jpeg",
},
processData: false,
data: fileContent,
})
.done(function(data, textStatus, jqXHR) {
console.log("HTTP Request Succeeded: " + jqXHR.status);
console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
console.log("HTTP Request Failed");
})
.always(function() {
/* ... */
});
Now to retrieve a file's content in a web browser, you probably want to use the HTML5 FileReader
. Here's an interesting answer for it: https://stackoverflow.com/a/29176118/1698645