From b5275719bbec93a3119abee84757374bb07354d6 Mon Sep 17 00:00:00 2001 From: p3k Date: Wed, 23 May 2007 14:34:48 +0000 Subject: [PATCH] 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) --- helma/Ftp.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/helma/Ftp.js b/helma/Ftp.js index 239b0c83..cbf8ae16 100644 --- a/helma/Ftp.js +++ b/helma/Ftp.js @@ -9,9 +9,9 @@ * Copyright 1998-2007 Helma Software. All Rights Reserved. * * $RCSfile: Ftp.js,v $ - * $Author: czv $ - * $Revision: 1.4 $ - * $Date: 2007/02/08 00:41:30 $ + * $Author: hannes $ + * $Revision: 1.5 $ + * $Date: 2007/02/08 09:12:21 $ */ @@ -417,6 +417,26 @@ helma.Ftp = function(server) { 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. *