Reply from SivaPrasad on Apr 10 at 11:23 AM You can use peoplecode function DetachAttachment to to cause the browser to display a save dialog box to the user.
| | | ---------------Original Message--------------- From: ACPhoenix Sent: Thursday, April 05, 2012 3:38 PM Subject: Download a File from the Fileserver to Local Machine Folder I created something similar to retrieve a list of user selected attachments to a specified directory. I used GetAttachment to move the selected file(s) to the AppServer, then used JavaObjects FileInputString and FileOutputString to write the AppServer files to the specified destination directory. This code is on a button on the page, in component field change PeopleCode. Prior to this, component field edit PeopleCode confirms the destination folder is available to the AppServer user (not the local user) by starting the log file. ... ... ... If &arrFileDownload <> Null Then &fileCopyAttachLog.WriteLine(" "); Local JavaObject &toJByteArray = CreateJavaArray("byte[]", 4096); For &i = 1 To &arrFileDownload.Len &strCopyFileSource = &arrFileDownload [&i][2]; &strCopyFileTarget = &strWRKFilePath | &arrFileDownload [&i][1]; If All(&strCopyFileSource, &strCopyFileTarget) Then try Local JavaObject &jFileInput = CreateJavaObject("java.io.FileInputStream&quo t;, &strCopyFileSource); Local JavaObject &jFileOutput = CreateJavaObject("java.io.FileOutputStream&qu ot;, &strCopyFileTarget); Local number &len, &rc; Local number &loop = 0; Repeat &rc = &jFileInput.read(&toJByteArray); If &rc > 0 Then &jFileOutput.write(&toJByteArray, 0, &rc); End-If; /* prevent run away - 4 gig */ &loop = &loop + 1; If &loop > 1000000 Then Break; End-If; Until &rc <= 0; &jFileInput.close(); &jFileOutput.close(); &jFileInput = Null; &jFileOutput = Null; &fileCopyAttachLog.WriteLine(getCurDttm() | " " | "Copy document " | &arrFileDownload [&i][1] | " to " | &strCopyFileTarget | " Successful."); catch Exception &jCopyException If &jFileInput <> Null Then &jFileInput.close(); End-If; If &jFileOutput <> Null Then &jFileOutput.close(); End-If; &toJByteArray = Null; &jFileInput = Null; &jFileOutput = Null; &fileCopyAttachLog.WriteLine(getCurDttm() | " " | "* * * W A R N I N G * * *"); &fileCopyAttachLog.WriteLine(getCurDttm() | " " | "Copy document " | &arrFileDownload [&i][1] | " to " | &strCopyFileTarget | " NOT Successful."); end-try; End-If; End-For; &toJByteArray = Null; End-If; ... ... ... | | Reply to this email to post your response. __.____._ | _.____.__ |
No comments:
Post a Comment