×

Discussion Board

Results 1 to 1 of 1
  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    11

    uploading image via http

    Hi all,

    I am uploading image via HTTP from phone.

    My code woks fine with Resin as web server, but it fails with Tomcat as server, ie it sends only partial image for large sized images.

    I am sending image binary data in Post body, & using content-type as image/jpeg.

    Is there any other way to do the same,
    may be using Content-type as Multipart/form-data.

    Below is the code on the phone:

    void CIapAppView::PublishImageL()
    {
    _LIT(KAttachmentFileName, "Image.jpg");

    //open image from images folder
    TFileName path = PathInfo::PhoneMemoryRootPath(); //Default
    path.Append( PathInfo::ImagesPath() );
    path.Append(KAttachmentFileName);

    TInt err=0;
    TRAP(err, AddToStatusWindowL(path));
    if(err)
    Panic(EIapView);


    RFs fs;
    User::LeaveIfError(fs.Connect());

    RFile infile;
    TInt val=infile.Open(fs,path,EFileShareExclusive|EFileRead);
    if(val==KErrNone)
    {
    TInt file_size;
    infile.Size(file_size);

    HBufC8* bufImageData;
    bufImageData = HBufC8::NewL(file_size);

    if(bufImageData)
    {
    TBuf8<256> data8;
    while(ETrue)
    {
    if(infile.Read(data8)!=KErrNone)
    {
    TRAP(err, AddToStatusWindowL(_L("Error: reading file")));
    if(err)
    Panic(EIapView);

    infile.Close();
    fs.Close();
    return;
    }
    if(data8.Length()==0) //eof
    {
    TRAP(err, AddToStatusWindowL(_L("Success: reading file")));
    if(err)
    Panic(EIapView);

    iClient->CancelTransaction();

    //use bufImageData to send http post
    TBuf8<256> uri8;

    //external public ip
    _LIT8(url1, "http://61.246.187.164/Push2Publish/Image?imageName=myimage&identityID=11");

    //internal public ip
    //_LIT8(url1, "http://192.168.102.11/Push2Publish/Image?imageName=myimage&identityID=11");

    //nitins ip
    //_LIT8(url1, "http://192.168.5.67:8080/Push2Publish/Image?imageName=myimage&identityID=11");

    uri8.Append(url1);

    TPtr8 ptr_bufImageData=bufImageData->Des();
    iClient->IssueHTTPPostL(uri8, _L8("image/jpeg"), ptr_bufImageData);


    break;
    }

    TPtr8 ptr_bufImageData=bufImageData->Des();
    ptr_bufImageData.Append(data8);

    }


    }
    else
    {
    TRAP(err, AddToStatusWindowL(_L("Error: Allocating HBuf")));
    if(err)
    Panic(EIapView);
    }

    }
    infile.Close();
    fs.Close();
    }

    Thanks

    Nitin
    Last edited by nit28in; 2005-05-16 at 12:27.

Posting Permissions

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