Professional Web Applications Themes

store/retrieve images to server - Macromedia Flex General Discussion

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....

  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. #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

Similar Threads

  1. unable to retrieve or display images from sql database
    By blog123456 in forum Macromedia Dynamic HTML
    Replies: 0
    Last Post: November 1st, 09:43 AM
  2. store and retrieve flash in and from database
    By kulderzipke in forum Macromedia Flash Data Integration
    Replies: 0
    Last Post: March 31st, 02:48 PM
  3. Web Custom Control - Retrieve Images from a Multifile Assembly
    By MLibby in forum ASP.NET Building Controls
    Replies: 2
    Last Post: September 8th, 09:14 AM
  4. How to store objects in array and the retrieve them
    By J.P. in forum PHP Development
    Replies: 4
    Last Post: August 20th, 02:12 PM
  5. Storing Images in SQL Server - ASP storage and retrieve
    By Michael Walton in forum ASP Database
    Replies: 10
    Last Post: January 9th, 06:50 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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