Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-1611

iOS: base64 encoding/decoding of Blob cannot be round-tripped successfully

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Trivial
    • Resolution: Duplicate
    • Affects Version/s: Release 1.7.2
    • Fix Version/s: Release 1.8.0
    • Component/s: iOS
    • Labels:

      Description

      {html}<div><p>This was already addressed for android as lighthouse ticket
      <a href="/projects/32238/tickets/1604" title=
      "Ticket #1604">#1604</a>, below are Bill's original notes from the
      bug.</p>
      <p>You cannot use Titanium.Utils.base64encode &
      Titanium.Utils.base64decode successfully to round-trip the encoding
      / decoding of a blob. In other words, you don't get back the same
      set of bytes that you originally started with.</p>
      <p>Failcase app.js (make sure you have KS_nav_ui.png in your
      Resources folder; it's there by default with new projects):</p>
      <p>var win = Ti.UI.createWindow({fullscreen: true, exitOnClose:true});</p>
      <p>var file = Ti.Filesystem.getFile('KS_nav_ui.png');</p>
      <p>var blob1 = file.read();<br>
      var base64 = Ti.Utils.base64encode(blob1);<br>
      var blob2 = Ti.Utils.base64decode(base64);</p>
      <p>var thumbnail1 = Titanium.UI.createView({left: 0, top: 0, width: 46, height: 43});<br>
      thumbnail1.backgroundImage = 'KS_nav_ui.png'; // the orig, which
      obviously works<br>
      var thumbnail2 = Titanium.UI.createView({left: 56, top: 0, width: 46, height: 43});<br>
      var thumbnail3 = Titanium.UI.createView({left: 112, top: 0, width: 46, height: 43});<br>
      win.add(thumbnail1); win.add(thumbnail2); win.add(thumbnail3);</p>
      <p>var tempDir = Titanium.Filesystem.createTempDirectory();<br>
      tempDir.createDirectory();</p>
      <p>// Blob from original file var file1 =
      Titanium.Filesystem.getFile(tempDir.nativePath, 'file1.png');<br>
      file1.write(blob1);<br>
      thumbnail2.backgroundImage = file1.nativePath;</p>
      <p>// Base64 encoded-then-decoded blob var file2 =
      Titanium.Filesystem.getFile(tempDir.nativePath, 'file2.png');<br>
      file2.write(blob2);<br>
      thumbnail3.backgroundImage = file2.nativePath;</p>
      <p>win.open();<br>
      You should see three identical images when that runs. Instead,
      you'll see only two.</p></div>{html}

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                stephentramer Stephen Tramer
                Reporter:
                thomashuelbert Thomas Huelbert
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-1459
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Source Code