jarens
03/20/2020, 1:31 PMtype":"error.SuiteScriptError","name":"UNEXPECTED_ERROR","message":null,"stack":["anonymous(N/file)","onRequest(/SuiteScripts/NFG BJ SL Test Upload.js:48)"],"cause":{"type":"internal error","code":"UNEXPECTED_ERROR","details":null,"userEvent":null,"stackTrace":["anonymous(N/file)","onRequest(/SuiteScripts/NFG BJ SL Test Upload.js:48)"],"notifyOff":false},"id":"da8c4901-f893-42f8-8658-6b73bb0bd000-2d323032302e30332e3230","notifyOff":false,"userFacing":false}
Anyone know what might be going on here? It's an SFTP connection, I was able to establish and look through the directories as well as download from it. Doing an upload and I'm getting the above. Simple code... but maybe I'm missing something. First time working with the SFTP module.
var myFile = file.load({
id: 21185724
});
connection.upload({
file: myFile,
directory: ''
});SimonC
03/20/2020, 2:17 PMSandii
03/20/2020, 2:19 PMSandii
03/20/2020, 2:22 PMtry {
connection = sftp.createConnection({
username: 'xxx',
passwordGuid: myPwdGuid,
url: '<http://xxx.com|xxx.com>',
directory: '/relative/filepath',
hostKey: myHostkey
});
} catch (e) {
log.error({
title: 'connection error',
details: e.message
});
context.write({
key: 'connection',
value: e.message
});
}
//loops through values array and builds master string
var results = context.values;
var final = "";
for (var i = 0; i < results.length; i++) {
final = final + results[i];
}
//used for naming the file
var date = new Date();
var tdate = date.getDate();
var month = date.getMonth() + 1; // jan = 0
var year = date.getFullYear();
var currentDate = month + '.' + tdate + '.' + year;
var fileName = 'file upload ' + currentDate;
//file creation to post to SFTP and save in file cabinet
var fileobj = file.create({
name: fileName,
fileType: file.Type.PLAINTEXT,
contents: final,
folder: someid,
isOnline: true
});
var id = fileobj.save();
try {
//attempt to upload to SFTP
connection.upload({
directory: '/',
filename: fileName,
file: fileobj,
replaceExisting: true
});
} catch (e) {
log.error({
title: 'upload failed',
details: e.message
});
context.write({
key: 'upload',
value: e.message
});
}Sandii
03/20/2020, 2:22 PMbattk
03/20/2020, 2:30 PMjarens
03/20/2020, 2:59 PMbattk
03/20/2020, 3:00 PMjarens
03/20/2020, 3:01 PMjarens
03/20/2020, 3:27 PMbattk
03/20/2020, 3:31 PMjarens
03/20/2020, 4:22 PMjarens
03/20/2020, 4:23 PMbattk
03/20/2020, 4:27 PMbattk
03/20/2020, 4:28 PMbattk
03/20/2020, 4:28 PMjarens
03/20/2020, 4:28 PMjarens
03/20/2020, 7:38 PMbattk
03/20/2020, 7:40 PMbattk
03/20/2020, 7:41 PM