Last active
April 5, 2016 21:39
-
-
Save Mozu-CS/74f4b611e02241c2b808f57f0ac8218c to your computer and use it in GitHub Desktop.
This currently does not work as it should.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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