×

Discussion Board

Page 1 of 3 123 LastLast
Results 1 to 15 of 37
  1. #1
    Regular Contributor
    Join Date
    Oct 2009
    Location
    Chennai, India
    Posts
    120

    Image Download using HTTP GET

    Hullo friends,

    I am creating an application to download an image file from url. For this, i used http client example. Under the EGotResponseBodyData, I can take the body data and write it into a file with somename.jpg. But the problem is, when downloading, if the original filesize is 50kb, i get only 5 kb or 6 kb in device. For some reason i am not getting the image properly.

    Is the method correct for downloading using HTTP GET?
    Last edited by hrkrshn; 2009-11-17 at 05:57.
    Nothing Is Impossible
    hk :)

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

    Re: Image Download using HTTP GET

    Maybe you could see whether the body comes in multiple parts.. So check what events and how many of them you are getting..

  3. #3
    Regular Contributor
    Join Date
    Aug 2009
    Location
    Bangalore, India
    Posts
    454

    Re: Image Download using HTTP GET

    Hi...
    I am also facing the same problem with HTTPClient example...its getting copied only 6KB to the file.
    If I dont write to the file & display directly on the emulator, then it is showing all the text.

    Writing on Emulator Properly (300KB):
    Code:
    void CClientAppView::AddToOutputWindowL(const TDesC8& aText)
      {
      // Convert 8-bit aText to 16-bit and append it to end of output window
      HBufC* tempBuf = HBufC::NewL(aText.Length());
      CleanupStack::PushL(tempBuf);
      tempBuf->Des().Copy(aText);
      CRichText* text = iOutputWindow->RichText();
      text->InsertL(text->DocumentLength(), *tempBuf);
      iOutputWindow->HandleTextChangedL();
      CleanupStack::PopAndDestroy(tempBuf);
      }
    Writing to file (only 6KB is writing) :
    Code:
    void CClientAppView::AddToOutputWindowL(const TDesC8& aText)
      {
      RDebug::Print(_L("Entering CClientAppView::AddToOutputWindowL()"));
      // Convert 8-bit aText to 16-bit and append it to end of output window
      HBufC8* tempBuf = HBufC8::NewL(aText.Length());
      CleanupStack::PushL(tempBuf);
      tempBuf->Des().Copy(aText);
      //CRichText* text = iOutputWindow->RichText();
      //text->InsertL(text->DocumentLength(), *tempBuf);
      iOutputWindow->HandleTextChangedL();
    
      TPtr8 tempBufPtr = tempBuf->Des();			
      
        //Writing plain text to the file
    	RFs fsSession;
    	User::LeaveIfError(fsSession.Connect());
    	RFile file;
    
    	TInt err=file.Open(fsSession,KEncryptedOutputFileName,EFileShareExclusive|EFileWrite);
    	if (err==KErrNotFound) // file does not exist - create it
    	 {
    	 RDebug::Print(_L(" ****Inside Inside Inside***** "));
    	 err=file.Create(fsSession,KEncryptedOutputFileName,EFileShareExclusive|EFileWrite);
    	 }
    
    	file.Write(tempBufPtr);			 
    	file.Close();
    
    	CleanupStack::PopAndDestroy(); //tempBuf
    	fsSession.Close();
    
      RDebug::Print(_L("Exit CClientAppView::AddToOutputWindowL()"));
      }
    What could be the problem ?
    Regards,
    Sunitha.M

  4. #4
    Regular Contributor
    Join Date
    Aug 2009
    Location
    Bangalore, India
    Posts
    454

    Re: Image Download using HTTP GET

    still facing the same problem........
    Regards,
    Sunitha.M

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

    Re: Image Download using HTTP GET

    And how have you tried on figuring out what is happening, did you try out what I suggested earlier:

    Quote Originally Posted by symbianyucca View Post
    Maybe you could see whether the body comes in multiple parts.. So check what events and how many of them you are getting..

  6. #6
    Regular Contributor
    Join Date
    Oct 2009
    Location
    Chennai, India
    Posts
    120

    Re: Image Download using HTTP GET

    As sunitha says, I can download images less than 6KB! But i am not sure about the reason though. For larger images, body consists of several parts, each separated with large space. In HTTPClient, the compiler calls the iObserver.ClientBodyReceived( dataChunk ) function, assuming data is over!

    So, can u give us an idea of how to split those spaces and get the entire data?
    Nothing Is Impossible
    hk :)

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

    Re: Image Download using HTTP GET

    there really should not be any large space, maybe, you could just use RFile, and store the whole content of the multiple parts into it, so you could see in the end what kind of data is actually received..

  8. #8
    Regular Contributor
    Join Date
    Aug 2009
    Location
    Bangalore, India
    Posts
    454

    Re: Image Download using HTTP GET

    these events are getting called :

    writing to emulator :
    *** EGotResponseHeaders ***
    *** EGotResponseBodyData ***

    aEventDescription = 2755 bytes received... // these are StatusWindowL calls
    aEventDescription = 6144 bytes received...
    aEventDescription = 2048 bytes received...

    around 30 calls for 6144 & 2048 bytes

    aEventDescription = 1025 bytes received...

    *** EResponseComplete ***
    *** ESucceeded ***

    writing to file :
    *** EGotResponseHeaders ***
    *** EGotResponseBodyData ***

    aEventDescription = 1295 bytes received... // these are StatusWindowL calls
    aEventDescription = 1460 bytes received...

    aEventDescription = 6144 bytes received...
    aEventDescription = 2048 bytes received...

    around 30 calls for 6144 & 2048 bytes

    aEventDescription = 1025 bytes received...

    *** EResponseComplete ***
    *** ESucceeded ***

    How come it is showing everything ie(300KB) on Emulator ? & why is it not writing to the file more than 6KB ?
    Regards,
    Sunitha.M

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

    Re: Image Download using HTTP GET

    so you get 30 calls for 6144 & 2048 bytes, so just see what comes in, I'm certain that actually contains the data you are querying for..

  10. #10
    Regular Contributor
    Join Date
    Aug 2009
    Location
    Bangalore, India
    Posts
    454

    Re: Image Download using HTTP GET

    Quote Originally Posted by symbianyucca View Post
    so you get 30 calls for 6144 & 2048 bytes, so just see what comes in, I'm certain that actually contains the data you are querying for..
    I have observed that only the last chunk is getting write to the file.

    I wrote the code as shown in #3

    If my original file is 300KB, and if it takes 30 chunks....

    only 30th chunk & part of 29th chunk are getting write to the file in the reverse order ie 30,29

    what is the reason ?
    Regards,
    Sunitha.M

  11. #11
    Registered User
    Join Date
    Jul 2009
    Posts
    259

    Re: Image Download using HTTP GET

    Quote Originally Posted by hrkrshn View Post
    Hullo friends,

    I am creating an application to download an image file from url. For this, i used http client example. Under the EGotResponseBodyData, I can take the body data and write it into a file with somename.jpg. But the problem is, when downloading, if the original filesize is 50kb, i get only 5 kb or 6 kb in device. For some reason i am not getting the image properly.

    Is the method correct for downloading using HTTP GET?
    Ya the GET Method is correct for downloading any file, image video file or whatever. And it gets written to the file also.

  12. #12
    Regular Contributor
    Join Date
    Aug 2009
    Location
    Bangalore, India
    Posts
    454

    Re: Image Download using HTTP GET

    Quote Originally Posted by joy.mca View Post
    Ya the GET Method is correct for downloading any file, image video file or whatever. And it gets written to the file also.
    Do u have any idea why it is writing only 6KB of the file ?
    Regards,
    Sunitha.M

  13. #13
    Registered User
    Join Date
    Jul 2009
    Posts
    259

    Re: Image Download using HTTP GET

    Quote Originally Posted by sunitha.m13 View Post
    Do u have any idea why it is writing only 6KB of the file ?
    Can you please show me your code of MHFRunL function in your ClientEngine class?

  14. #14
    Regular Contributor
    Join Date
    Aug 2009
    Location
    Bangalore, India
    Posts
    454

    Re: Image Download using HTTP GET

    Quote Originally Posted by joy.mca View Post
    Can you please show me your code of MHFRunL function in your ClientEngine class?
    I am not writing in MHFRunL func, I am writing at CClientAppView::AddToOutputWindowL()

    & I have posted the code in #3
    Regards,
    Sunitha.M

  15. #15
    Registered User
    Join Date
    Jul 2009
    Posts
    259

    Re: Image Download using HTTP GET

    Quote Originally Posted by sunitha.m13 View Post
    I am not writing in MHFRunL func, I am writing at CClientAppView::AddToOutputWindowL()

    & I have posted the code in #3
    Where have you wrote your code THTTPEvent::EGotResponseBodyData ? You would need this for the data part

Similar Threads

  1. How to download a PNG image over http?
    By agajewski in forum Mobile Java General
    Replies: 2
    Last Post: 2008-10-03, 05:50
  2. How to download an image from an URL using HTTP on S60 ?
    By gangaraju in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2008-05-22, 13:19
  3. HELP: Mutable Image to Immutable Image?
    By rj_cybersilver in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2005-03-26, 09:58
  4. Replies: 0
    Last Post: 2003-07-24, 10:46
  5. Upload and Download files using Wap instead of HTTP
    By arizkohli in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2003-07-19, 22:19

Posting Permissions

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