Send image multipart (Thread)

I send image divided into some parts (about 500 bytes per part) from my device through http connection. after i send image part,MIDlet listen for the response from server. If the response received then i send the next part....
The problem is: in emulator it works fine but in real device it often doesn't received the response (probably because of the poor quality of gprs in my country) so it looks hang up.. i'm trying to solve this by adding Command to continue (it will send the last part again) but it catch IlegalStateThreadException
how can i stop myThread that is currently running and waiting for response that will never come... and start the thread for re-send the part again?????

Friends
I am writting a application to send Image object from midlet to a servlet and save that as a file on server. I am converting Image to byte[] and at the server end reading the data from stream and save it.
I am converting Image to byte array line by line and writting it over http connection line by line.
the problem is I am not able to save the real image at server.
The file gets created of the size of the data sent but not able to open the image.
the code for image to array [] is
if (initialized) {
if (hasNextLine()) {
// Get one line of pixels out of the image, each integer value
// represents a pixel (0xAARRGGBB)
int[] temp = new int[width];
raster.getRGB(temp, 0, width, 0, y, width, 1);
// Convert pixels to gray scale, byte is sufficient
byte[] pixels = new byte[width];
for (int x = 0; x < temp.length; x++) {
// Get brightness of pixel (R + G + B) / 3; ignore alpha
pixels[x] = (byte) ((((temp[x] & 0x00FF0000) >> 16)
+ ((temp[x] & 0x0000FF00) >> 8) + (temp[x] & 0x000000FF)) / 3);
// Process and compress the image line
byte[] processedImgLine = processImageLine(pixels);
byte[] compressedImgLine = compressImageLine(processedImgLine);
// Update position in image
y++;
return compressedImgLine;
// No more lines
else {
throw new NoSuchElementException("No more lines in image");
and writing it in while loop line by line
and at the server side
InputStream in = request.getInputStream();
BufferedReader r = new BufferedReader(new InputStreamReader(in));
StringBuffer buf = new StringBuffer();
String line;
while ((line = r.readLine()) != null) {
buf.append(line);
String s = buf.toString();
// write a file
FileOutputStream f1;
File directory = new File("C:/Image/");
directory.mkdirs();
String path = "C:/Image/image.jpeg";
//byte[] data = Base64.decode(s);
ImageIcon imageIcon = new ImageIcon(s.getBytes());
Image image = imageIcon.getImage();
System.out.println(" Image "+image);
ImageIO.write(toBufferedImage(image), "jpeg",
new File("C:/Image/jpeg.jpeg")) ;Can anyone tell me the solution

Similar Messages

  • How to send image as a part of body with java mail

    How to send image (.GIF) file in mail body & not as an attachement using java mail API

    You need to create a multipart/related message.
    You'll probably find examples in this forum.

  • Unable to SEND images in BBM and What's App

    I am unable to send images in BB Messanger and What's App. The SEND oprion does not appear when i try to forward an image to bbm contact. In What's App it shows 'Upload Failed'. Apprears to be some common setting problem on the Blackberry. Any ideas of how to resolve

    Could you explain how you're going about to send an image via BBM?
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • "Rend Error" when sending image via iChat/AIM

    On my brand new iMac aluminum, I am unable to send, and friends are unable to send, images via iChat AIM 3.1.8 (V445). When either of us try to send, we get the message "An undefined AIM error has occured. The server message was: Rend: Error"
    I then spin around and use my old G4 iMac to send an image - no problem. My buddy is also able to send to me, no problem.
    Both computers are connected to the same Linksys WRT54G router. When I searched for the term 'rend' only one thread came back which suggested to change the port from 5190 to 443. I did this and it didn't help.
    Any other suggestions?

    Hi Craig,
    In the Linksys set up pages you have Application and Gaming (Which is where I think you are talking about)
    In there there are several options.
    Port Forwarding, Port Triggering, DMZ (possibly UPnP Forwarding and QoS)
    Disable any Port Forwarding or Port Triggering. DO not use the DMZ.
    Save settings. (you should still have Web browsing and Mail abilities).
    GO to the Administration tab on the top row.
    Enable UPnP.
    Save Settings.
    UPnP allows multiple computers to use the same ports.
    This way the Linksys can be left doing DHCP if you wish and it will not matter if your computer gets a new IP every now and then. Also the Ports are opened by the application and close after a timed period of non use.
    You can limit the "Hops" to the number of devices the computer is from the Linksys (1 ?) to make it more secure.
    On the main set up page you could limit the the DHCP range to the number of computers you have to prevent outside connections.
    The ports you describe so far are only the TExt chatting and file sending ports
    11:23 AM Monday; August 13, 2007

  • How to send image file through mail without   any attachment

    Plz tell  me how to send image file through mail without any attachment  ( i mean not converting  that image into pdf or any format )  i want to send that text or image  through mail .

    Hi Sandeep,
    I think you can setup the type of email in Shared office Settings in transaction S016.
    There is an option called <Preset document classes>
    You choose this pushbutton to branch to the maintenance screen for the document classes that are directly displayed to users in the Business Workplace for selection when they use the Create function. The name under which the documents are displayed can also be maintained.
    http://help.sap.com/saphelp_nw70/helpdata/en/6c/69c30f418d11d1896e0000e8322d00/content.htm
    Haven't tried it though.
    Regards,
    Siddhesh

  • How to send images using SOAP adapter

    hi All,
    I want to send images using the SOAP adapter . ( Sender and Receiver )
    Can anybody help out with this requirement
    Regards,
    Loveena

    Hi,
    Following links may help U
    /people/siva.maranani/blog/2005/09/03/invoke-webservices-using-sapxi
    http://help.sap.com/saphelp_nw04/helpdata/en/3c/b4a6490a08cd41a8c91759c3d2f401/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/29/5bd93f130f9215e10000000a155106/frameset.htm
    to know the basics about soap adapter u cn check out this link
    /people/padmankumar.sahoo/blog/2005/02/15/an-overview-of-soap
    to get in detail about the attachments chk out this link
    hi i am unable to attach an attachment in File to mail scenario
    Regards
    Pullarao

  • How to send images through PI using SOAP adapter

    hi,
    Can anybody tell me how to send images through PI using SOAP adapter.
    Regards ,
    Loveena

    Hi Loveena,
    only as attachments of a SOAP message.
    Regards,
    Udo

  • After updating to ios 6.1.3 I cant send images through imessage

    Hello

    That’s strange that my description in my first post is not showing up
    I have noticed that after I updated my iOS on my iPhone 5 to 6.1.3 the iMessage can no longer send images to other iDevices
    Sending regular text works but once an image is attached the message informs me that it has not been delivered and a red exclamation mark appears
    I tried to send images from multiple networks
    LTE
    3G
    3 different WiFi networks
    All of these fail
    I also reset my device from a backup and reset my network settings with no luck
    I really hope that this gets fixed soon because I do use imessage to send photos to my friends that have their own iDevices

  • Some recipients receive my images attached to emails, some find they are embedded and difficult to impossible to separate. Just found out that if I remove my attached signature, the problem goes away. How to send images   signature reliably?

    Some recipients receive my images attached to emails, some find they are embedded and difficult to impossible to separate. Just found out that if I remove my attached signature, the problem goes away. How to send images plus signature reliably?

    When you attach things, make sure to check the box that says [√] Send Windows-Friendly attachments

  • How to send images using Tuxedo 6.5

    What would be the best way to send images( bmp, jpeg, gif) using Tuxedo 6.5? Ideally,
    I would like to keep the image with the data, ie., have the image as a field in
    the FML32 buffer. I can't see anyway of doing this... Create a new buffer type??
    Thanks
    Rich

    Rich,
    How about storing the binary image in an FML field of type CARRAY?
    Be aware of the performance impact of very large buffers - >75% of MSGMNB (I
    think) and they're transferred by file i/o -
    Regards,
    Peter.
    Rich Wojcik wrote:
    What would be the best way to send images( bmp, jpeg, gif) using Tuxedo 6.5? Ideally,
    I would like to keep the image with the data, ie., have the image as a field in
    the FML32 buffer. I can't see anyway of doing this... Create a new buffer type??
    Thanks
    Rich

  • When I send image attachments through Mail they are received as very small and squashed. How can I change this?

    I have a problem sending image attachements (e.g., jpeg, png files etc) with the Mail utility from my MacBook Pro.  When people receive my email the attached image shows up not as an attached file that can be saved or downloaded, but as just a very small, squashed up version of the image imbedded in the email message itself.
    I usually add these attachments by simply dragging and dropping the desired file into the window of the email text. Is this the wrong way to do it?
    thanks
    Jerry

    Is this the wrong way to do it?
    The safest way to send images is to create a compressed file and send that.
    Click the image you want to send, go to File in the menu bar and select Compress... You end up with a file with a .zip at the end. Attach that to your email. Then trash the .zip file.
    The person at the other end only has to double click the .zip attachment.
    You can compress are single image or a folder of them.

  • Sending image in mail

    Hi,
    I have a requirement to send image in mail.
    I got a code from a post which is as following :
    import javax.mail.* ;
    import javax.mail.internet.* ;
    import java.util.Properties;
    class SimpleMail1 {
        public static void main(String[] args) throws Exception{
            System.out.println("Sending mail...");
            Properties props = new Properties();
            props.setProperty("mail.transport.protocol", "smtp");
            props.setProperty("mail.host", "smtp.mymailserver.com");
            props.setProperty("mail.user", "myuser");
            props.setProperty("mail.password", "mypwd");
    Session mailSession = Session.getDefaultInstance(props, null);
            mailSession.setDebug(true);
            Transport transport = mailSession.getTransport();
    MimeMessage message = new MimeMessage(mailSession);
            message.setSubject("HTML  mail with images");
    // write sender's and recpient's email address
       message.setContent
              (" img src=image_path" + "html/text");;    
            transport.connect();
            transport.sendMessage(message,
                message.getRecipients(Message.RecipientType.TO));
            transport.close();
    Here, the image is being taken from an internet link whereas I am working on Linux server.
    If I place a file on some location on the server, how to get the file from this location in this code?
    Regards,
    Nikhil

    Cary,
    I got your email overnight.
    The 5 attachments are full size JPEG files, and the overall size of the message is 4.5 MB. Three of them have been compressed more than the other two, which you can see looking at the file sizes shown in the attached screenshot I sent back to you, but all of them decompress into full size photos of good size.
    You may have muddied the water slightly, by Forwarding rather than sending a new message as you did originally. That can easily be checked if you open the message as originally sent, click on Message in the menubar and choose Send Again -- then change the To address to mine.
    However, I think there is another issue causing the message to be sent in Rich Text Format, which causes some conversion of text to HTML, which then is problematic to some email clients some recipients use on Windows computers, notably Outlook and Outlook Express. Specifically, the file name of each photo appearing beneath and between each attachment can cause this, as could multiple fonts (but you did have that). To stop the file name printing, which is coming from iPhoto's preparation of the message, change the selection in the Email dialogue in iPhoto to deselect Include Title and Include Comments.
    Then be sure to send all such messages in Plain Text, and be sure to use Windows Friendly if not already.
    Ernie

  • Until recently I was able to send images in the body of my Yahoo emails. Now, I am getting the message "This message has been truncated", and the email does not go through. I do not have this problem using IE. Could you please help? Thank you.

    Until recently I was able to send images in the body of my Yahoo emails. Now, I am getting the message "This message has been truncated", and the email does not go through. I do not have this problem using IE. Could you please help? Thank you.

    Try this -> http://support.apple.com/kb/TA38632?viewlocale=en_US

  • IMessage problem sending images on Wi-Fi

    Hi,
    A couple of weeks ago, after many years working without a glitch, I started experiencing sporadic erros when sending images on iMessage when connected to my home wifi. The problem seems to occurr with our iPhones but not with our iPads, however because the sporadic nature of the problem we just might have not experienced it yet. Nevertheless it happens so often with our iPhones and we've never seen it happen on one f our iPads.
    The charaterization of the problem is I try to send an image on iMessage, the progress bar hangs very near the end for an unusually long time, and eventually I get a red exclaim sign with the word Failure next to it. If I switch to 3G (which ***** because it consumes my dataplan), it works fine. I have a DSL ISP and 2 Airport Extremes networked thru a gigabit cable and configured as a Closed (non broadcasting SSID) Roaming Network.
    Corrective actions taken so far. I reset one of the iPhones back to factory settings. I've turned off the DSL Modem and both Airports, waited 30 seconds, and then turn everything back on.
    Any ideas?
    Thank You,
    Erasmo.

    I have exactly the same problem, I have been search for solution for many month already, so far Apple haven't give any solution to this problem. Still need wait for answer.

  • Mail not sending images

    A friend uses Mail on OS X (not sure which version) and can't send images inline. She's tried copying the image then pasting it within the body of the email message, but when it is received it shows either a question mark or a broken image icon.
    I have tried the same on my Mac (OS 10.4.11) and it works fine. Is there a setting that she needs to have set on her system in order for the images to be sent?
    Thanks.

    Thanks for the reply, Ernie.
    From what she's told me, she is copying image files from her desktop or some folder and pasting them into her emails. She can see the image that she pasted, but the images are not being sent, just the text. She wants to embed the images as opposed to attaching them because some of her recipients don't like opening attachments.
    I have done as she described and was able to succesfully send and receive (I sent them to myself and opened the email in another reader) the emails.
    I had her check her preferences, and in the View section all selections were checked as they are in mine. Is there something else that should be selected within Mail to allow embedded images to be sent?
    Thanks again.
    Ted

Maybe you are looking for