Two Problems: Directory contents listing & File uploading
Posted: Fri Aug 07, 2009 1:01 pm
by Andrew Campbell >> Tue, 8 Aug 2006 9:29:17 GMT
Hello JADE Tech General Forum members and JADE Support Personnel
This forum posting is in regards to certain difficulties I am experiencing with Jade 6.1.07 -Developer Edition.
I am attempting to list every file contained within a directory and the "FileFolder" class appears to be the only programmatical solution available within the Jade 6.1 System.
The problem with using the "FileFolder" class is that, when I implement such an instance in my current "Web-Enabled" Jade Application for the purpose of generating a file listing (through use of the browserForServerFolder() method), the returned value from the "browserForServerFolder() " and "files()" method contains only the current path for and files contained within the default directory. The default direction, in this case, is the database server root directory "C:\". The class instance appears to be unable to acquire files or information for any other folder that is selected from the displayed file and folder listing.
May I ask if there is an alternative within the Jade System for acquiring a file and directory listing for a given directory ? (preferably without the requirement of querying the user about which directory to inspect).
Another problem I am experiencing involves using a "TextBox" Form control (with the "webInputType" property value set to "TextBox.Web_InputType_File") to enable remote users to upload files. In my current implementation, when a file is selected by the client and the "Upload" button is clicked, a FileException (ErrorCode: 5030) is eventually thrown after a few moments due to the temporary file being accessed by another process. Previously, I was successful in allowing a single upload to complete, with following uploads failing for unknown reasons ( The "Page Not Found" browser page returned indicated that the server was not responding after the file upload ).
Attached are a few JADE source code extracts for elaborating on the situation.
Thank you for any assistance that you can offer.
Regards,
-Andrew Campbell
/******* ########################################################################### #####
*******/
cmdUpload_click(btn: Button input) updating;
vars
begin
handleFileUpload( txtUpload.text, MaterialManager.IMAGE );
end;
########################################################################### #####
handleUpload( text : String; type : Integer ) : String;
vars
path , tempPath, filename : String;
dPos : Integer;
begin
if text = null then return ""; endif;
path := '';
app.log.info( 'Uploaded file String: ' & text );
if( null <> type ) then
app.log.info( 'type = ' & type.display );
else
return null;
endif;
//app.log.info( 'type = ' & type.display);
//dPos := text.pos( ';', 1);
dPos := 1;
filename := text.scanUntil(';', dPos);
dPos := dPos + 1;
tempPath := text[ dPos : end ];
return transferUpload(filename, tempPath, type );
//populateListing;
end;
########################################################################### #####
transferUpload(filename : String; pathTemp : String; t : Integer) : String protected;
/*
this method stub has been automatically generated by Jade to satisfy interface implementation requirements
*/
vars
msgCopy, pathDest : String;
begin
msgCopy := '';
pathDest := '';
if filename = null or pathTemp = null then
app.log.error( 'filename and path Strings must be valid.' );
return null;
endif;
write 'Filename: '&filename;
write 'Temporary File Path: ' & pathTemp;
write 'MaterialManager.SOUND = ' & MaterialManager.SOUND.display ;
if( t = MaterialManager.IMAGE ) then
pathDest := $DEFAULT_PATH_IMAGES & filename;
app.log.info('Uploading image file.');
elseif( t = MaterialManager.SOUND ) then
pathDest := $DEFAULT_PATH_SOUNDS & filename;
app.log.info('Uploading audio file.');
elseif( t = MaterialManager.OTHER ) then
pathDest := $DEFAULT_PATH_MATERIALS & filename;
app.log.info('Uploading miscellaneous file.');
endif;
msgCopy := 'Source: ' & pathTemp & CrLf & 'Destination: ' & pathDest; app.log.info( msgCopy );
write msgCopy;
if( copy( pathTemp, pathDest) = false ) then
app.log.error('Problem copying file ' & pathTemp & ' to ' & pathDest );
else
app.log.info('Copy operation successful: copied file ' & pathTemp & ' to file ' & pathDest );
return pathDest;
endif;
end;
########################################################################### #####
copy( old, new : String) : Boolean;
vars
src, dest : File;
begin
if old = null or new = null then return false; endif;
create src transient;
create dest transient;
src.fileName := old;
src.mode := File.Mode_Input;
src.readOnly := true;
src.shareMode := File.Share_Read;
src.kind := File.Kind_Binary;
dest.fileName := new;
dest.mode := File.Mode_Output;
dest.shareMode := File.Share_Write;
dest.kind := File.Kind_Binary;
src.open();
dest.open();
dest.writeBinary( src.readBinary( src.fileLength() ) );
src.close();
dest.close();
return true;
end;
Hello JADE Tech General Forum members and JADE Support Personnel
This forum posting is in regards to certain difficulties I am experiencing with Jade 6.1.07 -Developer Edition.
I am attempting to list every file contained within a directory and the "FileFolder" class appears to be the only programmatical solution available within the Jade 6.1 System.
The problem with using the "FileFolder" class is that, when I implement such an instance in my current "Web-Enabled" Jade Application for the purpose of generating a file listing (through use of the browserForServerFolder() method), the returned value from the "browserForServerFolder() " and "files()" method contains only the current path for and files contained within the default directory. The default direction, in this case, is the database server root directory "C:\". The class instance appears to be unable to acquire files or information for any other folder that is selected from the displayed file and folder listing.
May I ask if there is an alternative within the Jade System for acquiring a file and directory listing for a given directory ? (preferably without the requirement of querying the user about which directory to inspect).
Another problem I am experiencing involves using a "TextBox" Form control (with the "webInputType" property value set to "TextBox.Web_InputType_File") to enable remote users to upload files. In my current implementation, when a file is selected by the client and the "Upload" button is clicked, a FileException (ErrorCode: 5030) is eventually thrown after a few moments due to the temporary file being accessed by another process. Previously, I was successful in allowing a single upload to complete, with following uploads failing for unknown reasons ( The "Page Not Found" browser page returned indicated that the server was not responding after the file upload ).
Attached are a few JADE source code extracts for elaborating on the situation.
Thank you for any assistance that you can offer.
Regards,
-Andrew Campbell
/******* ########################################################################### #####
*******/
cmdUpload_click(btn: Button input) updating;
vars
begin
handleFileUpload( txtUpload.text, MaterialManager.IMAGE );
end;
########################################################################### #####
handleUpload( text : String; type : Integer ) : String;
vars
path , tempPath, filename : String;
dPos : Integer;
begin
if text = null then return ""; endif;
path := '';
app.log.info( 'Uploaded file String: ' & text );
if( null <> type ) then
app.log.info( 'type = ' & type.display );
else
return null;
endif;
//app.log.info( 'type = ' & type.display);
//dPos := text.pos( ';', 1);
dPos := 1;
filename := text.scanUntil(';', dPos);
dPos := dPos + 1;
tempPath := text[ dPos : end ];
return transferUpload(filename, tempPath, type );
//populateListing;
end;
########################################################################### #####
transferUpload(filename : String; pathTemp : String; t : Integer) : String protected;
/*
this method stub has been automatically generated by Jade to satisfy interface implementation requirements
*/
vars
msgCopy, pathDest : String;
begin
msgCopy := '';
pathDest := '';
if filename = null or pathTemp = null then
app.log.error( 'filename and path Strings must be valid.' );
return null;
endif;
write 'Filename: '&filename;
write 'Temporary File Path: ' & pathTemp;
write 'MaterialManager.SOUND = ' & MaterialManager.SOUND.display ;
if( t = MaterialManager.IMAGE ) then
pathDest := $DEFAULT_PATH_IMAGES & filename;
app.log.info('Uploading image file.');
elseif( t = MaterialManager.SOUND ) then
pathDest := $DEFAULT_PATH_SOUNDS & filename;
app.log.info('Uploading audio file.');
elseif( t = MaterialManager.OTHER ) then
pathDest := $DEFAULT_PATH_MATERIALS & filename;
app.log.info('Uploading miscellaneous file.');
endif;
msgCopy := 'Source: ' & pathTemp & CrLf & 'Destination: ' & pathDest; app.log.info( msgCopy );
write msgCopy;
if( copy( pathTemp, pathDest) = false ) then
app.log.error('Problem copying file ' & pathTemp & ' to ' & pathDest );
else
app.log.info('Copy operation successful: copied file ' & pathTemp & ' to file ' & pathDest );
return pathDest;
endif;
end;
########################################################################### #####
copy( old, new : String) : Boolean;
vars
src, dest : File;
begin
if old = null or new = null then return false; endif;
create src transient;
create dest transient;
src.fileName := old;
src.mode := File.Mode_Input;
src.readOnly := true;
src.shareMode := File.Share_Read;
src.kind := File.Kind_Binary;
dest.fileName := new;
dest.mode := File.Mode_Output;
dest.shareMode := File.Share_Write;
dest.kind := File.Kind_Binary;
src.open();
dest.open();
dest.writeBinary( src.readBinary( src.fileLength() ) );
src.close();
dest.close();
return true;
end;