Added helma.Ftp.putBytes method for transfer of byte arrays, e.g. an image retrieved from a database. Btw: code is still formatted with indentation of 3 spaces (should be 4 afaik)

This commit is contained in:
Tobi Schäfer 2007-05-23 14:34:48 +00:00
parent c38a093d5c
commit b5275719bb

View file

@ -9,9 +9,9 @@
* Copyright 1998-2007 Helma Software. All Rights Reserved. * Copyright 1998-2007 Helma Software. All Rights Reserved.
* *
* $RCSfile: Ftp.js,v $ * $RCSfile: Ftp.js,v $
* $Author: czv $ * $Author: hannes $
* $Revision: 1.4 $ * $Revision: 1.5 $
* $Date: 2007/02/08 00:41:30 $ * $Date: 2007/02/08 09:12:21 $
*/ */
@ -417,6 +417,26 @@ helma.Ftp = function(server) {
return false; return false;
}; };
/**
* Transfers a byte array to a file on the FTP server.
* @param {Array} bytes The byte array that should be uploaded
* @param {String} remoteFile The name of the remote destination file
* @return Boolean True if the file was successfully uploaded, false if there was an error
* @type Boolean
*/
this.putBytes = function(bytes, remoteFile) {
try {
var stream = ByteArrayInputStream(bytes);
var result = ftpclient.storeFile(remoteFile, stream);
debug("putBytes", remoteFile);
return result;
} catch(x) {
error("putBytes", x);
setStatus(PUT);
}
return false;
};
/** /**
* Transfers a file from the FTP server to the local file system. * Transfers a file from the FTP server to the local file system.
* *