×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Oct 2005
    Location
    GuangZhou
    Posts
    526

    Hi, can anyone help me to solve this emergency problem?

    Hi, everyone, I want to upload a large file to server, and i use http post to upload, here is my code segment:
    <code>
    TInt CHttpXXX::SetHeader( )
    {
    if(iPostData==NULL)
    {
    iPostData = HBufC8::NewL(10000);
    }
    iStart = -1;

    TPtr8 iPostDataPtr = iPostData->Des();
    iPostDataPtr.Zero();
    iPostDataPtr.Append(_L("--AaB03x"));
    iPostDataPtr.Append(_L("\r\n"));
    iPostDataPtr.Append(_L("Content-Disposition: form-data; name=\"name\""));
    iPostDataPtr.Append(_L("\r\n\r\n"));
    iPostDataPtr.Append(_L("xxxxxxxxxxxxxxxx"));
    iPostDataPtr.Append(_L("\r\n"));

    iPostDataPtr.Append(_L("--AaB03x"));
    iPostDataPtr.Append(_L("\r\n"));
    iPostDataPtr.Append(_L("Content-Disposition: form-data; name=\"password\""));
    iPostDataPtr.Append(_L("\r\n\r\n"));

    iPostDataPtr.Append(_L("yyyyyyyyyyyyyyyy"));
    iPostDataPtr.Append(_L("\r\n"));

    iPostDataPtr.Append(_L("--AaB03x"));
    iPostDataPtr.Append(_L("\r\n"));
    iPostDataPtr.Append(_L("Content-Disposition: form-data; name=\"file\"; filename=\"xxx.png\""));
    iPostDataPtr.Append(_L("\r\n"));

    iPostDataPtr.Append(_L("Content-Type: image/png"));
    iPostDataPtr.Append(_L("\r\n\r\n"));

    TInt fileSize = GetFileSize(_L("C:\\DATA\\hello.png")); // this function I wrote for geting the file's size

    iDataLength = iPostDataPtr.Length() + fileSize;
    TBuf<50> buf(0);
    buf.Copy(_L("\r\n"));
    buf.Append(_L("--AaB03x"));
    buf.Append(_L("--"));

    iDataLength += buf.Length();

    return 0;
    }

    TBool CHttpXXX::GetNextDataPart(TPtrC8& aDataPart)
    {
    if(iStart == -1)
    {
    aDataPart.Set(iPostData->Des());
    iDataAvailable = ETrue;
    iStart = 0;
    return EFalse;
    }

    TPtr8 ptr = iPostData->Des();
    if(iStart<=GetFileSize(_L("C:\\DATA\\hello.png")))
    {
    ptr.Zero();
    TBuf8<6000>* temp = new(ELeave) TBuf8<6000>(0);
    CleanupStack::PushL(temp);
    LoadPartFileDataToBuffer(_L("C:\\DATA\\hello.png"), *temp, iStart, 5*1024);// this function is used for load a part data of the file, the last two parms is stand for the start index and the length
    ptr.Copy(*temp);
    iStart += 5*1024;
    aDataPart.Set(iPostData->Des());
    iDataAvailable = ETrue;
    iPartFinished = EFalse;
    CleanupStack::PopAndDestroy(temp);
    return EFalse;
    }
    else
    {
    ptr.Zero();
    ptr.Copy(_L("\r\n"));
    ptr.Append(_L("--AaB03x"));
    ptr.Append(_L("--"));
    aDataPart.Set(iPostData->Des());
    iDataAvailable = EFalse;
    return ETrue;
    }

    }

    void CHttpXXX::ReleaseData()
    {
    if(iDataAvailable)
    {
    iTransaction.NotifyNewRequestBodyPartL();
    }
    }

    TInt CHttpXXX::Reset()
    {
    return 0;
    }

    TInt CHttpXXX::OverallDataSize()
    {
    if(iPostData)
    return iDataLength;
    else
    return KErrNotFound;

    }
    </code>
    The code works on symbian 8.1a SDK, but just only work on emulator and can upload the file to the server can not work on 6680, when
    I upload a file, the screen has no response. And in symbian9.1 SDK, it can not work on emulator and device, I
    don't which part is wrong, can anybody help me? Thanks verymuch

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,169

    Re: Hi, can anyone help me to solve this emergency problem?

    it might help if you could explain a bit more on the problem, basically what gets executed and what doesn't, any error there, and so on..

Similar Threads

  1. Problem with eglSwapBuffers and heap corruption
    By greatape in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2007-05-24, 03:35
  2. Please solve iap_ id problem
    By sriramadasu in forum Symbian
    Replies: 0
    Last Post: 2006-09-26, 14:40
  3. 7210 Silent Problem
    By MarkMckim in forum Mobile Java General
    Replies: 1
    Last Post: 2003-03-18, 12:36

Posting Permissions

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