Re: Contacts API updates

On Wed, Jan 12, 2011 at 4:03 PM, Anssi Kostiainen <
anssi.kostiainen@nokia.com> wrote:

> On 6.1.2011, at 18.35, ext Rich Tibbett wrote:
>
> > On Thu, Jan 6, 2011 at 4:30 PM, Rich Tibbett <rich.tibbett@gmail.com>
> wrote:
> > I've updated the Contacts draft in line with recent discussions.
> >
> > As usual, the CVS log is available at [1] and changes from the previous
> version can be viewed via the diff log at [2].
> >
> > Please let me know if there are any outstanding changes to be made and
> thanks for all your input to date.
>
> Looks great! It would be cool if we could also use data URIs for
> adding/updating contacts (or calendar entries/...) as an alternative to the
> File Writer-based mechanism described here:
>
>  http://dev.w3.org/2009/dap/contacts/#adding-a-new-contact
>
> Actually, the following works in Chrome already:
>
> <a id="vcard">Save Contact</a>
>
> <script>
> var vcard = 'BEGIN:VCARD\n' +
>            'VERSION:3.0\n' +
>            'N:Doe;John;;;\n' +
>            'FN:John Doe\n' +
>            'TEL;type=CELL:123456\n' +
>            'END:VCARD';
>
> document.getElementById('vcard').href = 'data:text/x-vcard;charset=utf-8,'
> + encodeURIComponent(vcard);
> </script>
>
> It seems Chrome acts solely based on provided MIME-type (text/x-vcard), and
> does not require Content-Disposition header in order to trigger the
> Open/Save As dialog.
>

I could only get this to work in Chrome by right-clicking on the link and
selecting 'Save Link As...'.

I tested this in Opera, Firefox and Safari (all on Mac). Both Opera and
Firefox opens a download dialog on click and correctly identifies the data
URI as a vCard. Only Safari was unable to recognize the data URI as a vCard
file.

FWIW, I also tried changing the last line of your javascript with the
following that produced the exact same results:

document.getElementById('vcard').href =
'data:text/x-vcard;charset=utf-8;filename=contact.vcf;content-disposition=attachment,'
+ encodeURIComponent(vcard);


>
> I found a thread on this exact case but it seems it did not go anywhere:
>
>  http://lists.w3.org/Archives/Public/uri/2010Feb/0058.html


Disappointed that this was dropped as it seems we have inconsistency in the
browser implementation of data URI processing. It would be good for the W3C
URI group to clarify the intended behaviour of this since, at the very
least, browsers should handle the results in a similar way (and I'd suggest
Opera and Firefox as good references for how it should work).

Your use case is IMO valid and is an alternative ready-to-use-today way of
saving objects to the user's device.

Thanks!

Rich

Received on Wednesday, 12 January 2011 17:05:21 UTC