Skip to content

Instantly share code, notes, and snippets.

@Mozu-CS
Last active April 5, 2016 21:39
Show Gist options
  • Save Mozu-CS/74f4b611e02241c2b808f57f0ac8218c to your computer and use it in GitHub Desktop.
Save Mozu-CS/74f4b611e02241c2b808f57f0ac8218c to your computer and use it in GitHub Desktop.
This currently does not work as it should.
'use strict';
const fs = require('fs');
let FiddlerProxy = require('mozu-node-sdk/plugins/fiddler-proxy');
let apiContext = require('mozu-node-sdk/clients/platform/application')();
apiContext.plugins = [FiddlerProxy()];
const documentResource = require('mozu-node-sdk/clients/content/documentlists/document')(apiContext);
let filePath = __dirname + "\\bobafett.jpg";
let document = {
name: "bobafett.jpg",
documentTypeFQN: "image@mozu",
contentMimeType: "image/jpeg",
extension: "jpg",
properties: {
height: 300,
width: 300
}
};
let bobaFettPicture = fs.readFileSync(filePath);
document.contentLength = bobaFettPicture.length;
documentResource.createDocument({documentListName: "files@mozu"}, {body: document})
.then((addedPicture) => {
return documentResource.updateDocumentContent({documentListName: "files@mozu", documentId: addedPicture.id}, {body: bobaFettPicture});
})
.then((result) => {
console.log(result);
})
.catch((err) => {
console.error(err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment