×

Discussion Board

Results 1 to 5 of 5

Hybrid View

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    27

    Question How to upload a long video as a binary file to a server as Multipart/form-data

    Hi,

    I try to upload a video file from a Nokia 5800.
    I am writing my code based on http://wiki.forum.nokia.com/index.ph...part/form-data.
    My problem is that I have a big video file (e.g. 45MB) and when I try to create a buffer for the file a panic exception occurs.
    I guess it is not possible to create such a big buffer in memory.

    TFileName fileName;
    RFile iReqBodyFile;

    fileName.Copy(mFilePath);
    if (iFileServ.IsValidName(fileName)) {
    TInt iRetVal = iReqBodyFile.Open(iFileServ, mFilePath , EFileRead);
    if (KErrNone != iRetVal){
    return EFalse;
    }

    TInt ourFilesize = 0;
    User::LeaveIfError(iReqBodyFile.Size(ourFilesize));

    iReqBodySubmitBuffer = HBufC8::NewL(ourFilesize); // panic exception happens here
    TPtr8 aPtr= iReqBodySubmitBuffer->Des();
    TInt readerr = iReqBodyFile.Read(0,aPtr,ourFilesize);
    if (readerr != KErrNone){
    return EFalse;
    }

    iReqBodySubmitBuffer1 = NULL;
    iReqBodySubmitBuffer1 = HBufC8::NewL(xmlPtr.Length()+ending.Size()+aPtr.Length());

    TPtr8 iPostDataPtr = iReqBodySubmitBuffer1->Des();
    iPostDataPtr.Zero();
    iPostDataPtr.Append(xmlPtr); // some xml data
    iPostDataPtr.Append(aPtr);
    iPostDataPtr.Append(ending);
    }

    I debugged the code with Carbide.C++ v2.0 direct on the Nokia device.
    The debug exception output is:
    Signal 'Exception 100' received. Description: Thread 0x1ec has panicked. Category: E32USER-CBase; Reason: 47.


    Can somebody help me how to send a Multipart/form-data HTTP Post request with a large file?
    What needs to be done different?

    Thank you very much for your help

    Mirko

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

    Re: How to upload a long video as a binary file to a server as Multipart/form-data

    the error is "This panic is raised by the Error() virtual member function of an active scheduler, a CActiveScheduler. This function is called when an active object’s RunL() function leaves. Applications always replace the Error() function in a class derived from CActiveScheduler; the default behaviour provided by CActiveScheduler raises this panic. "

    So you should actually check what the original leave in RunL was, anyway, I belaive that you can use MHTTPDataSupplier to supply the data in parts for the post sending.

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    27

    Re: How to upload a long video as a binary file to a server as Multipart/form-data

    Hi symbianyucca,

    thank you for the response.
    In your response you said " I believe that you can use MHTTPDataSupplier to supply the data in parts for the post sending."

    Could you explain it in more details how i can assemble the post body part which contains a big file and send it with HTTP Post (Multipart/form-data) but transmit the body in chunks?

    Thank you for your help.

    Mirko

  4. #4
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143

    Re: How to upload a long video as a binary file to a server as Multipart/form-data

    I suppose GetNextDataPart gets called by the HTTP API and if you tell in there that it is not the last part, then it will be called again, thus you can supply the data in smaller parts..

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    27

    Re: How to upload a long video as a binary file to a server as Multipart/form-data

    Ok,

    I understand that.

    That would mean to me if i have to send a post body like this:

    --<boundary_string>
    Content-Type: application/atom+xml; charset=UTF-8
    API_XML_request
    --<boundary_string>
    Content-Type: <video_content_type>
    Content-Transfer-Encoding: binary
    <Binary File Data>
    --<boundary_string>--

    I would have some logic in GetNextDataPart which takes care of sending the data in 3 steps:
    1. Sending all post data prior to the binary file data.
    --<boundary_string>
    Content-Type: application/atom+xml; charset=UTF-8
    API_XML_request
    --<boundary_string>
    Content-Type: <video_content_type>
    Content-Transfer-Encoding: binary

    2. Sending the binary file data in chunks which each more GetNextDataPart call.
    <Binary File Data>

    3. If all binary data is send continue by sending the closing boundary string.
    --<boundary_string>--


    What do you think about that approach?

    Mirko

Similar Threads

  1. Replies: 3
    Last Post: 2008-09-09, 04:53
  2. [announce] PyUIQ. Python for UIQ 2.1 and 3.x
    By OscarBernabeu in forum Symbian
    Replies: 35
    Last Post: 2008-01-17, 09:12
  3. Error with makesis.exe and creating the .pkg file
    By gramya87 in forum Symbian Tools & SDKs
    Replies: 7
    Last Post: 2007-10-10, 13:53
  4. Replies: 1
    Last Post: 2005-05-26, 14:22
  5. Replies: 0
    Last Post: 2002-06-10, 12:24

Posting Permissions

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