Return-Path: X-Original-To: apmail-cordova-dev-archive@www.apache.org Delivered-To: apmail-cordova-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 05273DA7E for ; Thu, 7 Mar 2013 19:13:25 +0000 (UTC) Received: (qmail 44659 invoked by uid 500); 7 Mar 2013 19:13:24 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 44623 invoked by uid 500); 7 Mar 2013 19:13:24 -0000 Mailing-List: contact dev-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list dev@cordova.apache.org Received: (qmail 44615 invoked by uid 99); 7 Mar 2013 19:13:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Mar 2013 19:13:24 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lorin.beer.dev@gmail.com designates 209.85.223.171 as permitted sender) Received: from [209.85.223.171] (HELO mail-ie0-f171.google.com) (209.85.223.171) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Mar 2013 19:13:20 +0000 Received: by mail-ie0-f171.google.com with SMTP id 10so1029727ied.16 for ; Thu, 07 Mar 2013 11:13:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=gVyjzsP8GhEnkiDxwtLUaHndq857Y6s8cNj3gRu3l+I=; b=PjOtSCyIkPe8AVxYif1JrFkNbEEwraHlGIXwtE7xHT31Wdj7N7ua9w09QfCHvFCkkO MhZrVVHwY21iG1f+Q9D8g9D3zLVRTpsEohx4IuKis6+7zxzDDxJQvaJSz4gb+HqMkQHX T9ohoHw5+bkl/9KI8Y8F/IHRqEgyEOPNB0pSyrChinwUcpVaEXZNrEC8mvF/4FvJv6RN jXsbaqo7fuKn5wCxOBbt4i/3NgMywykuyeDlPGs6T/DGUFd7bmYi5Y3LTlTP9ygad4kP ikOt82QsBhxwSshOHEFQ9q5G2RVj0KK/mymmZCCO0xDO62avecz6gZ9f++GqyTPRaeSV tv5g== MIME-Version: 1.0 X-Received: by 10.50.153.198 with SMTP id vi6mr15638281igb.112.1362683580035; Thu, 07 Mar 2013 11:13:00 -0800 (PST) Received: by 10.64.8.167 with HTTP; Thu, 7 Mar 2013 11:12:59 -0800 (PST) In-Reply-To: References: Date: Thu, 7 Mar 2013 11:12:59 -0800 Message-ID: Subject: Re: Writing binary data to disk From: Lorin Beer To: dev@cordova.apache.org Content-Type: multipart/alternative; boundary=e89a8f22c681bab99204d75a7efd X-Virus-Checked: Checked by ClamAV on apache.org --e89a8f22c681bab99204d75a7efd Content-Type: text/plain; charset=ISO-8859-1 Andrew: that makes sense to me. It brings us closer in line with the w3c FileWriter spec. On Thu, Mar 7, 2013 at 9:57 AM, Andrew Grieve wrote: > The w3 spec says that FileWriter.write() accepts a Blob. Cordova's > currently accepts only strings. What I was suggesting is that we allow > either to be passed in. > > This will work only on iOS6+ and Android 3+ due to the lack of Blob support > on older versions. If we want to support older versions with this binary > ability, then maybe we could do something like: > > var base64str = ...; > var binaryData = CordovaBinary.fromBase64(base64str); > fileWriter.write(binaryData); > > > The exec() bridge could then check the type of the parameter and do the > right thing. > > > > On Wed, Mar 6, 2013 at 9:41 PM, Lorin Beer > wrote: > > > opps, amend the last message > > "the user *DOES* want to specify a hex or binary encoded string, and have > > that written as binary data on the native side" > > > > > > On Wed, Mar 6, 2013 at 6:40 PM, Lorin Beer > > wrote: > > > > > Andrew: > > > > > > the Cordova docs on FileWriter state that the data sent is written as a > > > UTF-8 string > > > http://docs.phonegap.com/en/2.5.0/cordova_file_file.md.html#FileWriter > > > The user doesn't want to specify a hex or binary encoded string, and > have > > > that written as binary data on the native side. As it sits now, > > providing a > > > hex string would write a unicode string of hex characters. > > > > > > In order to to have a hex or binary string actually be written as > binary, > > > we'd need to: > > > 1. pass an argument which explicitly sets the write mode, either to > > > FileWriter constructor or FileWriter.write > > > 2. set a state on FileWriter stating that the data string it receives > is > > > to be written in binary mode > > > > > > neither of these two options is explicitly part of the W3C spec on > > > FileWriter > > > > > > > > > On Wed, Mar 6, 2013 at 5:47 PM, Michal Mocny > > wrote: > > > > > >> We've added a way to send binary data across the android and ios > bridge > > >> (ArrayBuffers are a supported argument/message type). > > >> > > >> If you wanted to write a simple plugin to support writing binary data > to > > >> disk, it should be quite easy. > > >> > > >> Note: There are various limitations to the current way we send > > >> ArrayBuffers, such as being limited to very small sizes per call. We > > are > > >> soon going to be working on improvements here, expect JIRA issues and > > >> tests > > >> to come soon. > > >> > > >> -Michal > > >> > > >> > > >> On Wed, Mar 6, 2013 at 7:02 PM, Lorin Beer > > >> wrote: > > >> > > >> > Hey folks, > > >> > > > >> > I was going through the unassigned jira issues, and came across > > >> > CB-2406 > > >> > ((https://issues.apache.org/jira/browse/CB-2406), which requests a > > >> method > > >> > to write binary data to disk. Before commenting to the user on the > > >> issue, I > > >> > thought I'd get some feedback from you guys. > > >> > > > >> > My feeling is that while there might be a use case or two, > specifying > > a > > >> > binary write mode doesn't fit in with the W3C FileWriter > > >> > api, > > >> > and shouldn't be a change to the File API of cordova. As such, the > > issue > > >> > should probably be closed. > > >> > > > >> > The way in which the user would/should accomplish this kind of > > >> > functionality would be to create a very simple plugin which takes a > > hex > > >> > string and uses the native file writer api to open in binary mode. > > >> > > > >> > Before commenting to the user on the issue, I thought I'd get some > > >> feedback > > >> > from you guys. > > >> > > > >> > > > >> > - Lorin > > >> > > > >> > > > > > > > > > --e89a8f22c681bab99204d75a7efd--