Skip to Main Content

Oracle Forms

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

hi not able to download using webutil

Tony007Sep 22 2019 — edited Sep 26 2019

hi i have the following use case where i list file in server and i select file after i select i click the download button to save the file in client pc the issue am having is am not able to download

this is how am downloading

PROCEDURE download_file IS 

v_path_from_file_browser      varchar2(500) := null; 

v_filename                    varchar2(500);  

v_export_folder          varchar2(200); 

v_archive_folder              varchar2(200); 

v_file_transfer_success      boolean; 

BEGIN 

 

message('testinside'); 

  v_path_from_file_browser := CLIENT_GET_FILE_NAME(directory_name => :control.results_box, 

file_name    => :control.topdirectory, -- temp_filename - will replace below 

file_filter  => null, 

message      => 'Save A File', 

dialog_type  => SAVE_FILE); 

 

message('testinside '||v_path_from_file_browser); 

 

if v_path_from_file_browser is not null then 

 

 

 

 

 

 

:control.TOPDIRECTORY := v_path_from_file_browser; 

synchronize; 

 

 

                

host('unix2dos '||v_export_folder||v_filename||' '||v_ncs_export_folder||v_filename);--dev 

 

-- save the file in destination selected by user 

v_file_transfer_success := webutil_file_transfer.as_to_client_with_progress(v_path_from_file_browser||v_filename, 

                                                      :control.results_box, 

                                                      'Downloading ...', 

                                                      'OK'); 

 

 

host('unix2dos '||v_path_from_file_browser||v_filename||' '||v_path_from_file_browser||v_filename);--dev                                                      

if v_file_transfer_success then 

  message_warn('File transfer completed.');    

 

  EXIT_FORM(NO_VALIDATE); 

else 

  null;    

end if; 

 

end if; 

EXCEPTION 

when form_trigger_failure then 

raise; 

when others then 

null;--messa 

END; 

this how am listing the directory

Declare

-- For HOST call

  shellCmd varchar2(4000);

  parentdir varchar2 (3000);

  filename varchar2(2000); -- filename must include path and name 

  usr varchar2(50);

 

-- For TEXT_IO call

    thefilename    TEXT_IO.FILE_TYPE;

    LINEBUF  VARCHAR2(32766); -- 1 char less than 32k to account for ending line feed

temp VARCHAR2(32767);

cnt number := 0; -- display how many in list

Begin

CLEAR_MESSAGE;

:BLOCK1.D_COUNT := '';

usr := GET_APPLICATION_PROPERTY (USERNAME);

parentdir := :block1.topdirectory;

-- Ensure that the last character of the path is a /

IF INSTR (parentdir,'/',LENGTH(parentdir)-1) = 0 THEN

parentdir := parentdir || '/';

END IF;

-- Get directory list.

-- For production use, a more unique file name should be used so

-- other users don't over write each other.

filename := '/tmp/' || usr || '.txt';

-- Similar can be done on Windows using: dir /B /A:D

shellCmd  := 'ls -d ' || parentdir || '*/ > ' || filename;

  HOST (shellCmd);

   IF NOT form_success THEN

      message('Parent directory not found or not readable.');

      bell;

      raise form_trigger_failure;

   END IF;

-- List retrieved.  Now read contents of file.

DELETE_LIST_ELEMENT('BLOCK1.RTNDIRECTORIES', 1); -- Delete dummy entry required at design-time

thefilename := TEXT_IO.FOPEN(filename, 'R');

-- Loop through each line of text

LOOP

cnt := cnt + 1;

      TEXT_IO.GET_LINE(thefilename, LINEBUF);

      temp := temp + (length (LINEBUF));

      --Add each value to a t-list item      

      ADD_LIST_ELEMENT('BLOCK1.RTNDIRECTORIES', cnt, LINEBUF, LINEBUF);

END LOOP;

-- When no more data is found close text file

EXCEPTION

    WHEN NO_DATA_FOUND THEN

      TEXT_IO.FCLOSE(thefilename);

:BLOCK1.D_COUNT := cnt - 1;     

      HOST ('rm -f ' || filename); -- Delete tmp file containing list.

End;

Comments
Post Details
Added on Sep 22 2019
7 comments
741 views