You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2015/02/04 19:13:35 UTC
[jira] [Commented] (CB-7927) [WP8][cordova-plugin-file] Unable to
write a binary file.
[ https://issues.apache.org/jira/browse/CB-7927?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14305639#comment-14305639 ]
ASF subversion and git services commented on CB-7927:
-----------------------------------------------------
Commit 51435803f877c32f810de0ec5d1f89422d1719b2 in cordova-plugin-file's branch refs/heads/master from [~kdurkiewicz]
[ https://git-wip-us.apache.org/repos/asf?p=cordova-plugin-file.git;h=5143580 ]
[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