How to Save a file uploaded in WebDynpro Java to Windows server

Hi Guys,
I need to save a file uploaded in WebDynpro Java to a location on one of my companys many internal Window servers but I cannot get it to work.  I do not get any errors with the following code, but NOTHING happens...  And when I check the folder it is still emply...  Please advise.  I am particularly not sure about specifying the Path syntax.  Also, I do have permission to write to this server.  Is it even possible to save to a Windows server from WebDynpro??
//uploaded document already in context...
byte[] file = element.getFileResource();
            //    get the size of the uploaded file  
            element.setFileSize(this.getFileSize(file));
            wdContext.currentContextElement().setFSize(this.getFSize(file)); 
            //    get the extension of the uploaded file       
            element.setFileExtension(binaryType.getMimeType().getFileExtension());
            String fName = wdContext.currentContextElement().getFName();
            String fExt = wdContext.currentContextElement().getFileExtension();
            String foName1 = "
server01.w9\Files\P
HRP_Attachments\" + fName + ".pdf";
            File f1 = new File(foName1);
            DataOutputStream dos1;
            dos1 = new DataOutputStream(new FileOutputStream(f1));
            dos1.write(file);
            dos1.flush();
            dos1.close();
Edited by: christiaanp on Sep 30, 2011 8:07 AM

Hi Christiaan,
When specifying the path, make sure you escape the slashes
So, when you would normally use something like
\\server\path\file.txt
in your code you must use it in the form:
String fileName = "\\\\server\\path\\file.txt";
Hope this helps!
Robin van het Hof

Similar Messages

  • File upload in webdynpro java

    Hi, I have a reqirement where I have to upload the file ino server, and later user can down load the same from server.
    i have seen file upload and down load  example in SDN /docs/DOC-8061#15
    but here they are just displaying the name and other details of the file that is trying upload but they are not really uploading the file in to the server. can any one guide me how to upload the file and where does the uploaded file resides in the server once it is succeefully uploded.
    Regards,
    Venki.

    Hi Venki,
    The following is the Procedure to DownLoad File from the Server Path.
    1.) Take One Context Attribute named as "Texts" with Cardinality 0..n & Selection 0..1 & singleton = true .
    2.) Take Two Context Attributes named " FileName " & " urlValue " of type String Under above Node "Texts".
    3.) Bind Table UI Element & bind it's dataSource Property to the taken Context Node. Here it is "Texts".
    4.) Insert One Column to The Table UI Element.
    5.) Insert TableCellEditor( Take LinkToURL UI Element ).
    6.) Bind " Texts.urlValue " to the references Property of the LinkToURL UI Element.
    7.) Bind " Texts.FileName " to the text Property of the LinkToURL UI Element.
    8.) All The UpLoaded Files in the Folder "FolderXYZ" are appeared as rows in the Table.
    9.) Write the following code In the wdDoInit() Method of DownLoad View/After Upload Operation Performed.
         int count=0;
         WDWebResourceType obj=null;
         File folder=null;
         IWDMessageManager objMessageManager=wdComponentAPI.getMessageManager();
         folder=new File("FolderXYZ");  // The Folder Name which we gave in the Upload Code.
         File arr[]=folder.listFiles();
        if(arr==null)
              objMessageManager.reportWarning("No files exist in server.. Please Upload ");
              return;
         String str[]=new String(arr.length);
    Put Array brackets as it is a Array.
         String names[]=new String(arr.length);
    Put Array brackets as it is a Array.
         int c=0;
         for(int k=0;k<arr.length;k++)
           if(!(arr[k].isDirectory()))
               c++;
         int j=0;
         for(int i=0;i<arr.length;i++)
           try {
              if(!arr<i>.isDirectory())
                   FileInputStream fis = new FileInputStream(arr<i>);
                  FileChannel fc = fis.getChannel();
                   byte[] data = new byte((int)(fc.size()));
    Put Array  brackets as it is a Array.
                   ByteBuffer bb = ByteBuffer.wrap(data);
                   fc.read(bb);
                   IWDCachedWebResource objCachedWebResource = null;
                   if (data != null)
                     String sr[]=arr<i>.getName().split("
                     obj=new WDWebResourceType(sr[1],"html/"+sr[1],true);
                     objCachedWebResource = WDWebResource.getWebResource(data,obj);
                     objCachedWebResource.setResourceName(arr<i>.getName());
                   str[j]= objCachedWebResource.getAbsoluteURL();
                   names[j]=arr<i>.getName(); j++;
                   count++;
            }catch(Exception e)
                   objMessageManager.reportException("Unable to  get files from server "+e,false);
                   return;
         ArrayList al=new ArrayList();
         for(int k=0;k<count;k++)
              IPrivateHeaderDisplayView.ITextsElement test=wdContext.createTextsElement();
              test.setFileName(names[k]);
              test.setUrlValue(str[k]);
              al.add(test);
         wdContext.nodeTexts().bind(al);
         wdContext.currentContextElement().setVisibleCount(count);  
    With Regards,
    Roop Kumar.
    Edited by: Roop kumar Annavarapu on Sep 5, 2008 6:14 PM
    Edited by: Roop kumar Annavarapu on Sep 5, 2008 6:16 PM

  • File Upload from Webdynpro to R/3 Server

    Hi all
    We have a scenario. In that we want to upload any type of file (can be .txt, .pdf, .doc, .xls, .jpg, .gif etc.) to the R/3 server. We r using a FileUpload UI Element.
    The problem is we want to pass the contents of the file (any type of file) to the rfc.
    If anybody  knows the solution for this please help us.
    (It will be of great help if u give the code)
    Thanks & Regards
    Aparnna

    Hi Aparna,
    It happens becuse u r trying to access the byte array of the file in a loop.
    For small file it will not make any pblm, but for for big files, the loop may have to iterate millions of times which result in server hang.
    So dont try to access the byte array in loop in ur code. Try to pass the byte array u r getting as whole to RFC.
    Regards
    Fahad Hamsa

  • Excel File Upload In Webdynpro For ABAP

    Hi All,
    I have a doubt regarding EXCEL file upload for Webdynpro for ABAP.
    I am able to get the path of file using 'FILEUPLOAD' UI element.Now I need to upload the EXCEL file into ALV.I have tried out with GUI_UPLOAD and other excel upload function module.But these Function Module throws Dump.
    Can you please suggest how to go about it.It will be a great help if u can suggest any function module or method.

    Hi Amita,
    Insetad of using GUI_UPLOAD use 'HR_KR_XSTRING_TO_STRING'
    Here is the sample code,
    TYPES :BEGIN OF str_itab,
                  name(10) TYPE c,
                  age(10) TYPE c,
                 END OF str_itab.
    DATA : t_table1 TYPE STANDARD TABLE OF str_itab,
           i_data TYPE STANDARD TABLE OF string,
                   lo_nd_sflight TYPE REF TO if_wd_context_node,
                    lo_el_sflight TYPE REF TO if_wd_context_element,
                    l_string TYPE string,
            fs_table TYPE str_itab,
                    l_xstring TYPE xstring,
    fields TYPE string_table,
    lv_field TYPE string.
    DATA : t_table TYPE if_main=>elements_data_tab,
    data_table TYPE if_main=>elements_data_tab.
      * get single attribute
    wd_context->get_attribute(EXPORTING name =  `DATASOURCE`  
                              IMPORTING value = l_xstring ).
    CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
    EXPORTING
    in_xstring = l_xstring
    IMPORTING
    out_string = l_string.
    SPLIT l_string  AT
    cl_abap_char_utilities=>newline INTO TABLE i_data.
      * Bind With table Element.
    LOOP AT i_data INTO l_string.
    SPLIT l_string AT cl_abap_char_utilities=>horizontal_tab INTO TABLE
    fields.
    READ TABLE fields INTO lv_field INDEX 1.
    fs_table-name = lv_field.
    READ TABLE fields INTO lv_field INDEX 2.
    fs_table-age = lv_field.
    APPEND fs_table TO t_table1.
    ENDLOOP.
    lo_nd_sflight = wd_context->get_child_node( 'DATA_TAB' ).
    lo_nd_sflight->bind_table( t_table1 ).
      ENDMETHOD.
    if correct give correct answer
    Thanks & Regards,
    Meenachi.R

  • How do I share files uploaded into the Creative Cloud with other creative cloud members?

    How do I share files uploaded into the Creative Cloud with other creative cloud members?

    Should be easy.  Try this...
    In Thumbnails view, click the little triangle (pointing downward) in the lower-right corner of the asset you want to share.
    In the blue icon bar that appears, click the Share icon (the third icon from the left, just right of the trash icon). The Share dialog should pop up.
    In the Share dialog, enter the email address of the person with whom you want to share the asset, then click the Send Email button - they'll receive an email with a link to your asset. OR
    You can also copy a link to the asset and then paste that into your own email client if you prefer.  To do that, click the Link icon (looks like a "chain", and is to the right of the email "envelope" icon) - then click the Copy Link button.
    Note that the Share options won't be available if your asset is set to "Private" - you can control whether an asset can be viewed (or downloaded) by others by clicking the Public/Private control (green or red "lock" icon).
    You can also access the same Share controls if you click on the file to see it one-up (you can do this from either Thumbnails view or List view); click the Share icon near the upper right corner of the browser window (to the right of the asset name).
    Hope that helps.

  • How to save pdf file in database

    Dear All,
    my application is forms 6i and database is 8i,requirement is that how to save pdf file in database and users can view through forms

    I'll apologize up front for the length of this post. I have a few database procedures I created that write a file to a BLOB column in a table as well as retrieve the BLOB from the column after it stored there. I have successfully stored many different types of binary file to the database using these procedures - including PDF files. I have not used these procedures in a Form so I can confirm that they will work, but theoretically they should work. I'm including the code for each procedure in this posting - hence the apology for the long post! :-)
    Also, since these procedures reside on the database you will need to use Forms TEXT_IO built-in package to write your file to the server before you can use these procedures to store and retrieve the file from the database.
    These procedures reads and writes a binary file to a table called "LOB_TABLE." You will need to modify the procedure to write to your table.
    -- Author :  Craig J. Butts (CJB)
    -- Name   :  load_file_to_blob.sql
    --        :  This procedure uses an Oracle Directory called "IN_FILE_LOC".  If you
    --           already have a directory defined in the database or would prefer to use
    --           a different Directory name, make sure you modify line 21 to reflect the
    --           new Directory name.
    -- ==================================================================================
    -- History
    -- DATE        WHO         DESCRIPTION
    -- 12/11/07    CJB         Created.
    CREATE OR REPLACE PROCEDURE load_file_to_blob (p_filename IN VARCHAR2) IS
       out_blob    BLOB;
       in_file     BFILE;
       blob_length INTEGER;
       vErrMsg     VARCHAR2(2000);
    BEGIN
       -- set the in_file
       in_file := BFILENAME('IN_FILE_LOC',p_filename);
       -- Get the size of the file
       dbms_lob.fileopen(in_file, dbms_lob.file_readonly);
       blob_length := dbms_lob.getlength(in_file);
       dbms_lob.fileclose(in_file);
       -- Insert a new Record into the tabel containing the
       -- filename specified in P_FILENAME and a LOB_LOCATOR.
       -- Return the LOB_LOCATOR and assign it to out_blob.
       INSERT INTO lob_table (filename, blobdata)
          VALUES (p_filename, EMPTY_BLOB())
          RETURNING blobdata INTO out_blob;
       -- Load the file into the database as a blob.
       dbms_lob.open(in_file, dbms_lob.lob_readonly);
       dbms_lob.open(out_blob, dbms_lob.lob_readwrite);
       dbms_lob.loadfromfile(out_blob, in_file, blob_length);
       -- Close handles to blob and file
       dbms_lob.close(out_blob);
       dbms_lob.close(in_file);
       commit;
       -- Confirm insert by querying the database
       -- for Lob Length information and output results
       blob_length := 0;
       BEGIN
          SELECT dbms_lob.getlength(blobdata) into blob_length
            FROM lob_table
           WHERE filename = p_filename;
       EXCEPTION WHEN OTHERS THEN
          vErrMsg := 'No data Found';
       END;
       vErrMsg := 'Successfully inserted BLOB '''||p_filename||''' of size '||blob_length||' bytes.';
       dbms_output.put_line(vErrMsg);
    END;
    -- Author   :  Craig J. Butts (CJB)
    -- Name     :  write_blob_to_file.sql
    -- Descrip  :  This procedure takes a BLOB object from a database table and writes it
    --             to the file system
    -- ==================================================================================
    -- History
    -- DATE        WHO         DESCRIPTION
    -- 12/11/07    CJB         Created.
    CREATE OR REPLACE PROCEDURE write_blob_to_file ( p_filename IN VARCHAR2 ) IS
       v_blob      BLOB;
       blob_length INTEGER;
       out_file    UTL_FILE.FILE_TYPE;
       v_buffer    RAW(32767);
       chunk_size  BINARY_INTEGER := 32767;
       blob_position INTEGER := 1;
       vErrMsg     VARCHAR2(2000);
    BEGIN
       -- Retrieve the BLOB for reading
       BEGIN
          SELECT blobdata
            INTO v_blob
            FROM lob_table
           WHERE filename = p_filename;
       EXCEPTION WHEN OTHERS THEN
          vErrMsg := 'No data found';
       END;
       -- Retrieve the SIZE of the BLOB
       blob_length := DBMS_LOB.GETLENGTH(v_blob);
       -- Open a handle to the location where you are going to write the blob
       -- Note:  The 'WB' parameter means "Write in Byte Mode" and is only
       --          available in the UTL_FILE pkg with Oracle 10g or later.
       --        USE 'W' instead for pre Oracle 10q databases.
       out_file := UTL_FILE.FOPEN('OUT_FILE_LOC',p_filename, 'wb', chunk_size);
       -- Write the BLOB to the file in chunks
       WHILE blob_position <= blob_length LOOP
          IF ( ( blob_position + chunk_size - 1 ) > blob_length ) THEN
             chunk_size := blob_length - blob_position + 1;
          END IF;
          dbms_lob.read(v_blob, chunk_size, blob_position, v_buffer );
          UTL_FILE.put_raw ( out_file, v_buffer, TRUE);
          blob_position := blob_position + chunk_size;     
       END LOOP;  
    END;Hope this helps.
    Craig...
    -- If my response or the response of another is helpful or answers your question please mark the response accordingly. Thanks!

  • Could u plz help me to find simple example for how to save data file in a spread sheet or any other way in the real time controller for Sbrio 9642 using memory or usb flash memory

    Could u plz help me to find simple example for how to save data file in a spread sheet or any other way in the real time controller for Sbrio 9642 using memory or usb flash memory

    Here are a few Links to a helpful Knowledge Base article and a White Paper that should help you out: http://digital.ni.com/public.nsf/allkb/BBCAD1AB08F1B6BB8625741F0082C2AF and http://www.ni.com/white-paper/10435/en/ . The methods for File IO in Real Time are the same for all of the Real Time Targets. The White Paper has best practices for the File IO and goes over how to do it. 
    Alex D
    Applications Engineer
    National Instruments

  • How to save CSV file in application server while making infospoke

    How to save CSV file in application server to be used as destination while making infospoke.
    Please give the steps.........

    Hi
    If you want to load your flatfile from Application server,then you need to trasfer your file from your desktop(Computer) to Application server by using FTP.
    Try using ARCHIVFILE_CLIENT_TO_SERVER Function module.
    You Just need to give thesource path and the target path
    goto SE37 t-code , which is Function module screen, give the function name ARCHIVFILE_CLIENT_TO_SERVER, on click F8 Execute button.
    for path variable give the file path where it resides like C:\users\xxx\desktop\test.csv
    for target path give the directory path on Application server: /data/bi_data
    remember the directory in Server starts with /.
    U have to where to place the file.
    Otherwise use 3rd party tools to connect to ur appl server like : Core FTP and Absolute FTP in google.
    Otherwise...
    Goto the T.code AL11. From there, you can find the directories available in the Application Server.
    For example, if you wanna save the file in the directory "DIR_HOME", then you can find the path of the directories in the nearby column. With the help of this, you can specify the target path. Specify the target path with directory name followed by the filename with .CSV extension.
    Hope this helps
    regards
    gaurav

  • Does anyone know how to save a file in CC 10.0 or higher that is viewable in CC 9.2?

    I am trying to make my fiels viewable to someone who has Adobe CC version 9.2, but I have version 10.0. Does anyone know how to save my files so the are readable?

    You will likely get better program help in a program forum
    The Cloud forum is not about using individual programs
    The Cloud forum is about the Cloud as a delivery & install process
    If you will start at the Forums Index https://forums.adobe.com/welcome
    You will be able to select a forum for the specific Adobe product(s) you use
    Click the "down arrow" symbol on the right (where it says All communities) to open the drop down list and scroll

  • How to save iPhoto file in a separate portable hard disk drive?

    How to save iPhoto file in a separate portable hard disk drive?

    You want to move the iPhoto Library?
    Make sure the drive is formatted Mac OS Extended (Journaled)
    1. Quit iPhoto
    2. Copy the iPhoto Library from your Pictures Folder to the External Disk.
    3. Hold down the option (or alt) key while launching iPhoto. From the resulting menu select 'Choose Library' and navigate to the new location. From that point on this will be the default location of your library.
    4. Test the library and when you're sure all is well, trash the one on your internal HD to free up space.
    Regards
    TD

  • How to save Numbers file as Excel (XLSX) file ?

    I just want to know how to save Numbers files into Excel format. Because other than Mac users can't able to access Numbers format.

    File, Export To, Excel…

  • How to save psd files...

    how to save psd files so other can change (with all fonts and Layers)
    I need to know how to save everything in the psd so others still can use it.??

    Hi,
    If you have photoshop and you are working on it and have used layers , fonts , and other things
    Then after completing your work, click save and it will open save Box,
    make sure the file format in the box should be PSD and then you may save the file and then you can share with any one.
    Any one who has Photoshop will be able to open that file and can edit the layers and fonts..
    --Baljeet

  • How to download a file uploaded in the portal admin console

    Hi All ,
    I have created a content using admin console.
    It has a property called , "file", and it is of type "Binary".and its primary property
    I need to have link in JSP , to download that file/content.
    I am using <templates tag , but not able to download.
    Could you pls suggest how to download a file uploaded to admin console
    Thanks & Regards,
    Srinivas

    Srinivas,
    Check the WLP API http://e-docs.bea.com/wlp/docs102/javadoc/index.html?overview-summary.html
    Search for com.bea.content.manager.servlets.ShowBinaryServlet class and com.bea.content.manager.servlets.DownloadBinaryServlet class. You can use one of these depending on your requirment. I think there is not jsp tag for these classes so you have to use scriptlets.

  • How to save .pdf file using office word and excel

    Can someone help me how to save .pdf files using office word and excel?  I reinstalled my adobe 7.0 pro in my new pc and before I was able to do it but with my old pc.

    For anything after Office 2003, you have to print to the Adobe PDF printer. If you installed AA 7 on OS newer than XP, you may have to do a workaround to get it to work. With later versions of WORD you can always use the MS plugin for creating PDFs.

  • How to save image files into SQL Server?

    Hello, All:
    Does anyone know how to save image files into SQL Server? Does the file type have to be changed first?? Please help me! Thank you!

    You need a BLOB field (usually)... Then you can check this tutorial out:
    http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/exercises/BLOBPut/
    There are other exercises on that site, including one on reading the images back.

Maybe you are looking for

  • Problems with My Bt Website- any ideas?

    Hi I have been unable to access My Bt broadband usage monitor since Feb 2012. I gave up trying to get help with this as I don't expect to go over. However, I had an email telling me that I'd used 32gb out of 40gb. I was still ok for my 40gb limit las

  • Output type triggering

    Hi All, I am setting output type to create idoc in the NACE transaction code. But how to call the output type, when the fields(Contract number, description, sold-to-party) are changing. I found user-exit (EXIT_SAPLV45W_001). In this user-exit, I wrot

  • Adobe illustrator CS crashing

    Ok today when I went to use illustrator it crashed and would not open so I restarted the the power book and it still would not open.. so then I uninstalled illustrator and reinstalled it and it is still crashing... Anyone have any idea of how I can f

  • Upgrade to OS 10.5 from 10.4.11 - Login Issues?

    I just upgraded my 1 GHz iMac G3 from 10.4.11 to 10.5 with no problems...until the system rebooted and presented me with a login screen.  None of my previous identities work - and only an "Other" identity is present.  I have NO idea the login/passwor

  • Reader 10.1.3 99% CPU after launch XP

    We just upgraded to 10.1.3 from 9.4 and have 2 issues 1.  When launching reader when you attempt to close it looks like it closes but the process stays open and jumps to 99% CPU usage until killed.   I have tried disabling protected mode thinking tha