robmartin60
12/24/2019, 7:45 PM/**
*@NApiVersion 2.x
*@NScriptType ScheduledScript
*/
// Pass in all modules needed
define(['N/search', 'N/record', 'N/log', 'N/runtime', 'N/file', 'N/https', 'N/encode'], function(search,record, log, runtime, file, https, encode) {
function execute(context){
var url = '<https://users.ece.utexas.edu/~perry/education/382v-s08/papers/raymond.pdf>';
var response = https.get({url: url});
log.debug({title: 'getFile response', details: {code: response.code, headers: response.headers, encodingOut: encode.Encoding.BASE_64, encodingIn: encode.Encoding.UTF_8 }});
if(response.code == 200){
var contents = encode.convert({string: response.body, outputEncoding: encode.Encoding.BASE_64, inputEncoding: encode.Encoding.UTF_8})
log.debug({title: 'getFile response', details: contents});
var fileObj = file.create({name: 'The_Cathedral_and_the_Bazaar.pdf', fileType: file.Type.PDF, contents: contents, folder: 7562116});
fileObj.save();
}
}
return {
execute: execute
}
});
```battk
12/24/2019, 8:14 PMbattk
12/24/2019, 8:15 PMec
12/24/2019, 8:24 PMec
12/24/2019, 8:24 PMrobmartin60
12/27/2019, 4:28 PM