cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lorin Beer <lorin.beer....@gmail.com>
Subject Re: Writing binary data to disk
Date Thu, 07 Mar 2013 19:12:59 GMT
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 <agrieve@chromium.org> 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 <lorin.beer.dev@gmail.com>
> 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 <lorin.beer.dev@gmail.com>
> > 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 <mmocny@chromium.org>
> > 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 <lorin.beer.dev@gmail.com>
> > >> wrote:
> > >>
> > >> > Hey folks,
> > >> >
> > >> > I was going through the unassigned jira issues, and came across
> > >> > CB-2406<https://issues.apache.org/jira/browse/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<http://www.w3.org/TR/file-writer-api/#idl-def-FileWriter>,
> > >> > 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
> > >> >
> > >>
> > >
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message