Results 1 to 7 of 7

Thread: Problems Encoding to Base64

  1. #1

    Default Problems Encoding to Base64

    I am having problems encoding a file to base64.

    I want to send a pdf by mail so i have to encode it to base64

    When i do this:
    Qt Code:
    1. QString data;
    2. QFile file(filename);
    3. file.open(QIODevice::ReadOnly | QIODevice::Text);
    4.  
    5. while (!file.atEnd())
    6. {
    7. QByteArray line = file.readLine();
    8. data += line.toBase64();
    9. }
    To copy to clipboard, switch view to plain text mode 

    The string data seems to content all the information, but if i attached it into a mail i could not open the file

    I hope you could help me

    Sorry for my bad english

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problems Encoding to Base64

    You have to encode the whole string at once, not line by line.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems Encoding to Base64

    Secondly, is your MIME header correct?

  4. #4

    Default Re: Problems Encoding to Base64

    i have also tried readAll();

    But the result was the same...

    Yes the MIME is correct!

  5. #5
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems Encoding to Base64

    Then either post the complete code you use for generating the email, or post the generated email (as an attachment)

  6. #6
    Join Date
    Jul 2010
    Posts
    1
    Thanks
    1

    Default Re: Problems Encoding to Base64

    I encounter the same problem.
    I need to fill the postfields with base64 encoded.
    Qt Code:
    1. QFile sourceFile(filename);
    2. QByteArray srcRawData = sourceFile.readAll();
    3. QByteArray base64Encoded = srcRawData.toBase64();
    To copy to clipboard, switch view to plain text mode 

    But the web site doesn't recognize the base64 string.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problems Encoding to Base64

    What do you do with the encoded string?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Download attachments and Base64 coding
    By Altertwin in forum Qt Programming
    Replies: 1
    Last Post: 14th March 2010, 17:12
  2. How can i decode binary base64
    By Askar in forum Qt Programming
    Replies: 1
    Last Post: 14th September 2009, 03:01
  3. Replies: 5
    Last Post: 29th April 2009, 22:39
  4. Base64 vs Binay File format
    By rmagro in forum Qt Programming
    Replies: 4
    Last Post: 6th February 2009, 16:17
  5. Send Base64 encoded data
    By rmagro in forum Qt Programming
    Replies: 6
    Last Post: 29th October 2007, 16:58

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.