cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-7927) [WP8][cordova-plugin-file] Unable to write a binary file.
Date Tue, 02 Dec 2014 08:23:12 GMT

    [ https://issues.apache.org/jira/browse/CB-7927?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14231154#comment-14231154
] 

ASF GitHub Bot commented on CB-7927:
------------------------------------

GitHub user durkiewicz opened a pull request:

    https://github.com/apache/cordova-plugin-file/pull/95

    [CB-7927] Encoding data to bytes instead of chars when writing a file.

    This solves: https://issues.apache.org/jira/browse/CB-7927

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/durkiewicz/cordova-plugin-file CB-7927-wp8-writing-binary-files

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cordova-plugin-file/pull/95.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #95
    
----
commit 51435803f877c32f810de0ec5d1f89422d1719b2
Author: Kamil Durkiewicz <kamil.durkiewicz@avaus.fi>
Date:   2014-11-06T09:15:42Z

    [CB-7927] Encoding data to bytes instead of chars when writing a file.
    
    This solves: https://issues.apache.org/jira/browse/CB-7927

----


> [WP8][cordova-plugin-file] Unable to write a binary file.
> ---------------------------------------------------------
>
>                 Key: CB-7927
>                 URL: https://issues.apache.org/jira/browse/CB-7927
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin File
>    Affects Versions: 3.5.0
>         Environment: Windows Phone
>            Reporter: Kamil Durkiewicz
>              Labels: plugin-file, wp8
>         Attachments: patch.diff
>
>
> When this code is run on Windows Phone:
> {code:javascript}
> // a valid base64-encoded image:
>         var imgData = '/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAIBAQIBAQICAgICAgICAwUDAwMDAwYEBAMFBwYHBwcGBwcICQsJCAgKCAcHCg0KCgsMDAwMBwkODw0MDgsMDAz/2wBDAQICAgMDAwYDAwYMCAcIDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAz/wAARCAAHAAgDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDkPhh8d/FOp/FTxr8TbCfxDomsWlums6rc6DqktjA9iJo4BaXKx3EN3cpcXs2mxyT/AGs3ABmnk+0SkyKUUVHF3FFbA0MPWhRpTc3VjacOZJUqjpx5U37vuxV0rRbV7Jt3/urgfw0yrPMbjqGKqVYKh7DldOo4N+2oQrS52vjanOXK5Xaj7t2kj//Z',
>             path = 'testImage.jpeg';
>         var byteArray = base64DecToArr(imgData).buffer;
>         window.requestFileSystem(
>             LocalFileSystem.PERSISTENT,
>             0,
>             function(fileSystem) {
>                 fileSystem.root.getFile(path, { create: true }, function(fileEntry) {
>                     fileEntry.createWriter(function(writer) {
>                         writer.write(byteArray);
>                         writer.onwriteend = function(evt) {
>                             alert('write end');
>                         };
>                     })
>                 });
>             });
> {code}
> where base64DecToArr is a function taken from here: https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding
> The file that is written is not a valid jpeg file. This issue is caused by deserialization
of bytes into `char[]` instead of `byte[]`.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message