Two Problems: Directory contents listing & File uploading

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Two Problems: Directory contents listing & File uploading

Postby ConvertFromOldNGs » 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;

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Two Problems: Directory contents listing & File uploading

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:01 pm

by Murray Symon >> Thu, 10 Aug 2006 7:55:33 GMT

Hi Andrew,

It sounds like you're on the right track with the FileFolder class.

You can set the starting directory for the 'browseForFolder()' method by passing it a valid directory pathname in the first parameter.

Set the directory name by changing the 'fileName' attribute of the FileFolder object. You can use the String returned by 'browseForFolders()' here. Otherwise you can validate it with the 'isValidPathname()' method.

FileFolder::files() will only return files from that directory, to
find files in subdirectories will require recursion down the directory tree, possibly using more instances of the FileFolder class.

hth,
Murray.
Last edited by ConvertFromOldNGs on Wed Aug 12, 2009 10:01 am, edited 1 time in total.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Two Problems: Directory contents listing & File uploading

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:01 pm

by Patwos >> Thu, 10 Aug 2006 8:52:00 GMT

One thing to keep in mind, as this is a web enabled application, is that the browseForFolder dialog will not be visible to the Web Browser client but will actually get displayed on the machine hosting the Web enabled application. If you're testing this all on one machine you may not have realised this subtlety.

Hope that helps,
Pat.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 38 guests