store/retrieve images to server

Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default store/retrieve images to server

    Hi All,
    I want to retrieve images from server and send them back to Servlet without using FileUpload. It's an urgent requirement please help me out.

    Thanks in Advance.
    Surendra.
    Suren_kancherla Guest

  2. Similar Questions and Discussions

    1. unable to retrieve or display images from sql database
      Using Dreamweaver 8 and connecting to an Sql Server 2000 i am not able to display image files from the sql table. the other fields in the table are...
    2. store and retrieve flash in and from database
      Hi all, i stored an uploaded flash-file in a MS-SQL database. Now i want to retrieve this file from my database in ASP.NET, but I don't know how to...
    3. How to store objects in array and the retrieve them
      Hi, I'm trying to store objects in an array and then later I want to retrieve the object again. I tried it the following way, but it doesn't...
    4. Storing Images in SQL Server - ASP storage and retrieve
      I need some help, because I am utterly confused with how to do this. I have 2 things that I need to figure out, and could use some sample code or...
    5. How to store Images in SQL Table
      Define a column as image and just send the data to the image to this column as normal, usually as a byte array. See also the thread 'Why should I...
  3. #2

    Default Re: store/retrieve images to server

    This is not better solution. I encode image with base64 and send to servlet. In
    servlet i decode image to byte array and save to server.

    I would now better solution too.
    We have to waiting for someone who know more ... :)

    Flex:

    private function uploadImage():void {
    var params:Object = { fileName: _fileRef.name ,
    fileData: getBase64String(imgComponent)};
    myHttpService.send();
    }


    private function getBase64String(component:UIComponent):String {
    var bitmapData:BitmapData = new BitmapData(component.width, component.height,
    true, 0xffffff);
    bitmapData.draw(component);

    var encoder:IImageEncoder;
    // jpg, *.jpeg, *.gif, *.png
    if (_fileRef.type.toLowerCase() == 'jpg' || _fileRef.type.toLowerCase() ==
    'jpeg') {
    encoder = new JPEGEncoder(80);
    } else {
    encoder = new PNGEncoder();
    }

    var bytes:ByteArray = encoder.encode(bitmapData);

    var b64encoder:Base64Encoder = new Base64Encoder();
    b64encoder.encodeBytes(bytes);

    var b64String:String = b64encoder.flush();

    return b64String;
    }


    Java:

    import sun.misc.BASE64Decoder;
    import java.io.*;

    ...

    String UPLOAD_DOMAIN = "/MyUploadPath/";
    String fileName = request.getParameter("fileName");

    try {
    if (fileName != null) {
    BASE64Decoder base64 = new BASE64Decoder();

    // Decode base64 to byte array
    byte[] decodedData =
    base64.decodeBuffer(request.getParameter("fileData ").toString());

    // Save on server
    FileOutputStream fos = new FileOutputStream(UPLOAD_DOMAIN+fileName);
    fos.write(decodedData);
    fos.close();

    } else {
    System.out.println("ImageCutUpload (failed): file name is empty.");
    }
    } catch( IOException e ){
    System.out.println("ImageCutUpload (failed): write error: "+e);
    }

    klakiers Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139