How to download a file from a server

Hi,
I have a question with a general design implementation. Hope anyone more skilled than me helps me.
I want to do an application based on an android client and a java server. Local wifi transmission, no 3G.
Basically, the client must connect to the server and request a file to download using a code.
How can I do that?
Things I know:
* I must create a background thread in the client to create a file in the SD card and update a progress bar using a Handler to communicate with the UI thread.
* The server must be multithread and non-blocking.
* The file is a binary file like a mp3 audio. So the server has to:
1. Send information about the file: name and total length.
2. Open the file, read and send bytes while it does not reach the end.
* The client has to:
1. Receive the information about the file and create an empty file.
2. Read bytes and dump them into the empty file. Update progress bar.
3. When all bytes are recieved close the file.
I have knowledge implementing a client and server in C (very awful) but I am beginning with a real client-server application done in java.
Questions:
* How can I download a binary file like an mp3 from a server to a client?
* Where I have to put my server application? I supose that I must create a jar, save it on a folder and execute it at PC start-up, right?
Thanks!
PD: I know this is not an android forum but I only need help with the download process.
Edited by: user13425637 on 06-dic-2010 11:08

Questions:
* How can I download a binary file like an mp3 from a server to a client?There are a ton of examples on the internet on how to download files. If you are having a problem, please post your code.
>
* Where I have to put my server application? I supose that I must create a jar, save it on a folder and execute it at PC start-up, right?Your server application will exist on a server and will run the application. hence the reason for the server. The best best for you is to read some online tutorials on client/server and how it works.

Similar Messages

  • How to download a file from application server to presentation server

    Hi experts,
    I want to download a file from application server to presentaion server, file contaims three fields customer name, customer email id and status..
    help me out i m new into sap.

    Dear Aditya,
    Please check below thread
    http://scn.sap.com/thread/1010164
    it will help you.
    BR
    Atul

  • How to Download a file from web server using servlets

    how do we download a file from Java Web Server connecting to oracle database
    it should start as soon a i click a button in my html browser
    please reply as it is needed to complete my project to submited to the collage

    With SQLJ you can do it.
    When you look at:
    http://otn.oracle.com/sample_code/tech/java/sqlj_jdbc/files/basic/basic.htm
    or
    http://otn.oracle.com/sample_code/tech/java/sqlj_jdbc/files/advanced/advanced.htm
    There are samples for reading LONGRAW / BLOB from Database. If you want use it in servlet you have to pass the result to the responce object, set the correct mime-type and set the response.setContentLength( xx). This is for some PlugIns nessessary (pdf).
    regards Dietmar

  • How to download a file from Middleware server

    Hi,
    I have a requirement to list file names in a table layout and when user clicks on file name, file must be downloaded to the client tier. Source files are located in 11i Apps middletier.
    I did not find any examples on how to achieve this using OAF. All I see is downloading file from BLOB inside a database.
    please help..

    OAMessageDownloadBean is the bean that lets you download a file from middletier.
    Please see the File Upload and Download chapter in devguide for implementation details.
    Thanks
    Tapash

  • How to download a file from a server path?

    Is it possible to attach files on the server to a web dynpro response with cl_wd_runtime_services=>attach_file_to_response? All the examples I have seen assume you have the file content as an XSTRING. But how can one just send a file from a known path?
    Is it really necessary to first load the file (e.g. a 50Mb TIFF) as an XSTRING before downloading it? If so, how is this done?

    Hi Marc,
    Try using this FM to convert String to Xstring.
    SCMS_STRING_TO_XSTRING
    HR_KR_STRING_TO_XSTRING
    and also check this...Error document.getElementById(...)  in function 'SCMS_STRING_TO_XSTRING'
    Might Helps you.
    Cheers,
    Kris.

  • How to download a file from application server in webdynpro

    Hi Experts,
                       I am trying to download a file through Web Dynpro file download UI element..The file is stored in application server in binary format ..in my code i am reading the file in binary mode,converting Binary File into Xstring(Using FM SCMS_BINARY_TO_XSTRING) ..getting its Mime type and binding the UI element properties (data with XString, Mime type and file name) with respective context attributes..But the problem is file is getting opened but Junk data is getting displayed on it..Not sure where i am making the mistake.

    Hi Lukas,thanks for the reply..please find the code
    here '/tmp/accenturedocs'  is the folder name on application server,and zdocs_list_tab is the table that contains file URL.File upload is on the BSP page (custom logic to upload the file ) where they are storing local file path in ztable.Same i am extracting in my code to get File URL.
    DATA: i_file TYPE rlgrap-filename .
      DATA:v_path TYPE zlist.
      DATA:i_datatab TYPE STANDARD TABLE OF tbl1024,
           wa_datatab TYPE   tbl1024.
      DATA  file TYPE  string.
      DATA dot_offset TYPE i.
      DATA extension TYPE mimetypes-extension.
      DATA mimetype TYPE mimetypes-type.
      SELECT SINGLE description
        FROM  zdocs_list_tab
        INTO v_path.
      CONCATENATE '/tmp/accenturedocs' v_path INTO i_file.
      FIELD-SYMBOLS <hex_container> TYPE x.
      OPEN DATASET i_file FOR INPUT IN LEGACY BINARY MODE.
      IF sy-subrc NE 0.
        MESSAGE e999(00) WITH 'Error opening file' .
      ENDIF.
      ASSIGN  wa_datatab TO <hex_container> CASTING.
      DO.
        READ DATASET i_file INTO <hex_container>.
        IF sy-subrc = 0.
          APPEND wa_datatab TO i_datatab.
        ELSE.
          EXIT.
        ENDIF.
      ENDDO.
      CLOSE DATASET i_file.
      DATA:l_count TYPE i,
            l_len TYPE i.
      DESCRIBE TABLE i_datatab LINES l_count.
      READ TABLE i_datatab INTO wa_datatab INDEX l_count.
      l_len = XSTRLEN( wa_datatab-line ).
      l_len = l_len + ( l_count - 1 ) * 1022.
    DATA: v_xstring TYPE xstring.
      CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
        EXPORTING
          input_length = l_len
        IMPORTING
          buffer       = v_xstring
        TABLES
          binary_tab   = i_datatab
        EXCEPTIONS
          failed       = 1
          OTHERS       = 2.
      IF sy-subrc <> 0.
      ENDIF.
    file = i_file.
      " Find out file name extension
      FIND FIRST OCCURRENCE OF REGEX '\.[^\.]+$' IN file MATCH OFFSET
      dot_offset.
      ADD 1 TO dot_offset.
      extension = file+dot_offset.
      " Get mime type
      CALL FUNCTION 'SDOK_MIMETYPE_GET'
        EXPORTING
          extension = extension
        IMPORTING
          mimetype  = mimetype.
    DATA lv_file_content TYPE wd_this->element_context-file_content.
    get element via lead selection
      lo_el_context = wd_context->get_element( ).
    set single attribute
      lo_el_context->set_attribute(
        name =  `FILE_CONTENT`
        value =  v_xstring ).
    same way i am assigning file name and file mime type to context attributes.
    please suggest where is the mistake.

  • How to download a file from other server using servlet

    Hi All....
    Good Morning....
    right now,i am facing a problem..i am trying to download a file which is in other server..i tried somany ways and i couldnt succeed in this...
    will u pls give me solution for this..
    because it is very urgent for me...
    i am very much thankful if u provide me the code samples also....
    i am seeking ur help...
    Regards,
    sathya

    right now,i am facing a problem..i am trying to download a file which is in other server..i tried somany ways and i couldnt succeed in this...If you can tell some of our approaches and the failures you faced, someone might be able to help you.
    I dont think anyone will just give the code samples.

  • How to download a file from server?

    Hi everyone,
    I need to download a file from my server to client machine. I got a sample code from ur forum and I modified it slightly.
    //Snippet of code:
    public void doGet(HttpServletRequest req, HttpServletResponse res)throws
         ServletException, IOException{
    int bytesRead=0;
         int count=0;
         byte[] b1=new byte[1];
         //OutputStream out=res.getOutputStream();
         res.setContentType("application/html");
         //Create an input stream from file URL.
         String fileURL="http://localhost:8080/webapps/upload/upload.html";
         BufferedInputStream bis=null;
         BufferedOutputStream bos=null;
         boolean download=false;
         res.setHeader("Content-disposition", "attachment; filename=upload.html " );
         try{
         URL url=new URL(fileURL);
         URLConnection connection=url.openConnection();
         InputStream in=connection.getInputStream();
         bis=new BufferedInputStream(in);
         FileOutputStream fileout=new FileOutputStream("upload.html");
         bos=new BufferedOutputStream(fileout);
         while(-1 != (bytesRead = bis.read())){
         try{
         bos.write(bytesRead);
         bos.flush();
         }//end of try forwhile loop
         catch(SocketException e){
         setError(e);
         break;
    The code is getting compiled, when I run the appln using the URL,
    http://localhost:8080/upload/servlet/DownloadFile
    it opens a pop up dialog box, asking whether to "open", "save" or "cancel" buttons. When I try to open a file, I'm getting a blank page.
    I'm not getting the contents of the file.
    So pls can anyone tel me wht's wrong in the code or do i need to add few more lines in my code?
    Also pls let me know, how can I download any files of type .doc, html, .txt, .zip, or any type, without mentioning the file type?
    Thanks in advance

    Do not use a FileOutputStream (that will save it locally to the server). Call HttpServletResponse.getOutputStream(), which will send it back to the browser. Also remember to call close() on the stream at the end.
    - Saish

  • Downloading a file from App Server to User's Desktop

    Hi All,
    I know that there are many threads on file upload and download :-)
    I have tried to browse through most of them and could not find my solution.
    The requirement is to place a file in the unix app server directory and allow the user to download it using a link, to the user's desktop. In case you think that this has already been answered in an old thread, kindly give me the pointer. Any sample code for doing this, would be great.
    I know how to upload a file from desktop to table/app server. I know how to download a file from a BLOB column in database.
    Thanks,
    Amit

    You would not be able to use file upload or download beans, as they interact with the database and not the filesystem.
    You would need to write a simple file reader routing in plain java.
    Tapash

  • How to download a file from database

    Hi,
    My flex application contains a form that uploads a file into the server. This file is however saved in the database, and not on the disk. Most of the tutorials in the database explains how to download a file by passing the file's url to the "download" function of the fileReference Object. That dsnt work for me as my file is saved in the database.
    How do I download this file from the server ?
    For example, in php, we would do smthing like this :
    $content = $file_to_download['content'];
    $size = $file_to_download['content_size'];
    $type = $file_to_download['content_type'];
    $name = $file_to_download['filename'];
    header("Content-type:$type");
    header("Content-length:$size");
    header("Content-Disposition:attachment;filename=$name");
    header("Content-Description:PHP Generated Data");
    echo $content;
    When executing this file, it opens up the "download file" dialog box. How do i get the same effect in flex 4 ?

    You need the bytes use FileReference.download() and after download you can save
    it on disk with FileReference.save(); You also need FP 10 at least I think. Use
    the docs they are less error pron than mi memory :).
    C

  • How to download a file from Path specifed

    Hi Frndz..
    How to download a file from a specified path like  , i have a file on server in the path like "C://temp/Sap.pdf"
    I want to download this to user desktop..
    Thanks in Advance
    regards
    Rajesh

    Hi,
    For file down load u have to use a UI element as "File download".
    u just create context attribute as setdownload_res and file data.
    setdownload_res as of type "com.sap.ide.webdynpro.uielementdefinitions.Resource" then bound it to the ui element "resource".
    file data as of type "com.sap.tc.webdynpro.progmodel.api.IWDInputStream"
    and set calcuclated as true and read only as true.
    then in doinit method u just write this code
    IWDAttributePointer attr = wdContext.currentContextElement().getAttributePointer("fileData");
    IWDResource res = WDResourceFactory.createResource(attr,null,WDWebResourceType.UNKNOWN);
    wdContext.currentContextElement().setDownload_res(res);
    wdComponentAPI.getMessageManager().reportSuccess(""+c);
    after this in the getter method u write this code
    IWDInputStream stream = null;
    try
    stream = WDResourceFactory.createInputStream(new FileInputStream(new File("<pathof the file to be download>")));
    catch(Exception e)
    e.printStackTrace();
    return stream;
    also look at this thread  How to DownLoad any type of File from the server(PDF,XLS,Word)
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/202a850a-58e0-2910-eeb3-bfc3e081257f
    PradeeP

  • How to upload XML file from Application server.

    Hi,
    How to upload XML file from Application server.Please tell me as early as possible.
    Regards,
    Sagar.

    Hi,
    parameters : p_file type ibipparms-path obligatory.
    ***DOWNLOAD---->SAP INTO EXCEL
    filename1 = p_file.
    call function 'GUI_DOWNLOAD'
      exporting
      BIN_FILESIZE                    =
        filename                        = filename1
        filetype                        = 'ASC'
      APPEND                          = ' '
      WRITE_FIELD_SEPARATOR           = 'X'
      HEADER                          = '00'
      TRUNC_TRAILING_BLANKS           = ' '
      WRITE_LF                        = 'X'
      COL_SELECT                      = ' '
      COL_SELECT_MASK                 = ' '
      DAT_MODE                        = ' '
      CONFIRM_OVERWRITE               = ' '
      NO_AUTH_CHECK                   = ' '
      CODEPAGE                        = ' '
      IGNORE_CERR                     = ABAP_TRUE
      REPLACEMENT                     = '#'
      WRITE_BOM                       = ' '
      TRUNC_TRAILING_BLANKS_EOL       = 'X'
      WK1_N_FORMAT                    = ' '
      WK1_N_SIZE                      = ' '
      WK1_T_FORMAT                    = ' '
      WK1_T_SIZE                      = ' '
    IMPORTING
      FILELENGTH                      =
      tables
        data_tab                        = it_stock
      FIELDNAMES                      =
    exceptions
       file_write_error                = 1
       no_batch                        = 2
       gui_refuse_filetransfer         = 3
       invalid_type                    = 4
       no_authority                    = 5
       unknown_error                   = 6
       header_not_allowed              = 7
       separator_not_allowed           = 8
       filesize_not_allowed            = 9
       header_too_long                 = 10
       dp_error_create                 = 11
       dp_error_send                   = 12
       dp_error_write                  = 13
       unknown_dp_error                = 14
       access_denied                   = 15
       dp_out_of_memory                = 16
       disk_full                       = 17
       dp_timeout                      = 18
       file_not_found                  = 19
       dataprovider_exception          = 20
       control_flush_error             = 21
       others                          = 22
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    Regards,
    Deepthi.

  • How to download .doc file from ms sql

    Hi guys.,,,!
    I have a problem in file uploading and downloading. The problem is i upload my .doc file in ms sql server successfully completed. After that i would like to download the file from the database.can anybody tell that how to download the file from the database.

    mani_miit wrote:
    I have a problem in file uploading and downloading.OK.
    The problem is i upload my .doc file in ms sql server successfully completed. Sorry, I don't see a problem here? You said that it is successfully completed. Please elaborate the problem.
    After that i would like to download the file from the database.can anybody tell that how to download the file from the database.Just get an inputstream of the file from the database using ResultSet#getBinaryStream() and write it to the output of whatever UI technology you're using.

  • How to download a file from the net and save it into .txt format in a datab

    Can some one show me a tutorial on how to download a file from the net and save it into .txt format in a database?
    Thank you,

    http://java.sun.com/docs/books/tutorial/networking/urls/readingWriting.html

  • How to download a file from the internet using terminal

    how to download a file from the internet using terminal
    does any one know how to download afile from the internet using the Terminal application?

    Use curl. Something like this:
    curl -O http://www.example.com/filename.zip
    For more info, type +man curl+.

Maybe you are looking for

  • Free space problem in / with oracle-xe-11.2.0-1.0.x86_64

    Hi, I'm trying to install Oracle-xe-11g on Red Hat 5.6, but I have the following problem: [root@localhost] rpm -ivhf oracle-xe-11.2.0-1.0.x86_64.rpm Preparing... ########################################### [100%] installing package oracle-xe-11.2.0-1

  • Low power warning for AIR-LAP1242AG-C-K9

    Hi Buddie, We purchased some AIR-LAP1242AG-C-K9 , but not perchasing any wireless controller. When I connect the LAP to Cat2950 or Cat2960 PPoE port, all the LAP can not boot normally. It indicates low power, please refer the two pictures attached. B

  • IMac 24in screen gradient

    First let me apologize if I am repeating a post... I know that there has been a great deal of discussion online about gradient issues on the 24in iMac (mine is early 2007) however I have been unable to find any details or response from Apple themselv

  • Can a calendar from iphoto be printed anywhere?

    Can a calendar from iphoto be printed in another region than where the account is set up? I am in Switzerland and would like to get my calendar to the States for Christmas. There must be a way to print it in the States and have it delivered directly.

  • EXIT_ON_CLOSE

    Hi friends.... im new to java....on execting my first program im really stuck up in this command EXIT_ON_CLOSE wenever i comple...the error is "undefined variable EXIT_ON_CLOSE"....did i need to include any header files here????? public static void m