<br><span class="Apple-style-span" style="border-collapse: collapse; "><div class="im" style="color: rgb(80, 0, 80); "><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
Also, would it be possible to hook browser-produced data into this model, so client-generated data (f ex text, html, pdf) could be dragged out as a virtual file to the desktop?</blockquote><div><br></div></div>You could also extend the File API to allow for user created instances of FileData objects. This would be comparable to Java's Blob and Clob API.<div>
<br></div><div>Each "blob" could represent either a local file, http file, ftp file, in memory data or lazy client-generated data. This is all unknown to the target and it's very extensible.</div><div><br></div>
<div>Of course you could also create a data URL but you'd have to base64 encode it and keep the whole file in memory.</div><div><br></div><div>The key to having a "blob" API is the lazy nature of it. Of course a "blob" would only be living as long as the source document is still able to generate the content on-demand.</div>
<div><br></div><div>(<a href="http://blog.calyptus.eu/seb/2009/03/large-object-storage-for-nhibernate-and-ddd-part-1-blobs-clobs-and-xlobs/" target="_blank" style="color: rgb(51, 51, 204); ">Here's some semi-relevant info on this pattern in the context of DDD</a>.)</div>
<div><br></div><div>I'm not sure I like this though because the complexity involved compared to a "DownloadURL"-format. But there is a need to be able to do this with client-generated data as well.</div><div>
<br></div><div>Sebastian Markbåge</div><div><br></div></span><div class="gmail_quote">On Tue, Aug 18, 2009 at 10:31 AM, Mike Wilson <span dir="ltr"><<a href="mailto:mikewse@hotmail.com">mikewse@hotmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div>
<div dir="ltr" align="left"><font face="Verdana" color="#0000ff" size="2"><span>Sounds interesting!</span></font></div>
<div dir="ltr" align="left"><font face="Verdana" color="#0000ff" size="2"><span>You only mention a singular file, what do you think
about multiple files?</span></font></div>
<div dir="ltr" align="left"><font face="Verdana" color="#0000ff" size="2"><span></span></font> </div>
<div dir="ltr" align="left"><font face="Verdana" color="#0000ff" size="2"><span>Also, would it be possible to hook browser-produced
data into this model, so client-generated data (f ex text, html, pdf) could be
dragged out as a virtual file to the desktop?</span></font></div>
<div dir="ltr" align="left"><font face="Verdana" color="#0000ff" size="2"><span></span></font> </div>
<div dir="ltr" align="left"><font face="Verdana" color="#0000ff" size="2"><span>Best regards</span></font></div>
<div dir="ltr" align="left"><font face="Verdana" color="#0000ff" size="2"><span>Mike Wilson</span></font></div><br>
<blockquote dir="ltr" style="padding-left:5px;margin-left:5px;border-left:#0000ff 2px solid;margin-right:0px">
<div lang="en-us" dir="ltr" align="left">
<hr>
<font face="Tahoma" size="2"><b>From:</b> <a href="mailto:whatwg-bounces@lists.whatwg.org" target="_blank">whatwg-bounces@lists.whatwg.org</a>
[mailto:<a href="mailto:whatwg-bounces@lists.whatwg.org" target="_blank">whatwg-bounces@lists.whatwg.org</a>] <b>On Behalf Of </b>Jian
Li<br><b>Sent:</b> den 18 augusti 2009 03:03<br><b>To:</b>
<a href="mailto:whatwg@lists.whatwg.org" target="_blank">whatwg@lists.whatwg.org</a><br><b>Subject:</b> [whatwg] Proposal to drag virtual
file out of browser<br></font><br></div><div><div></div><div class="h5">
<div></div>
<div>SUMMARY</div>
<div><br></div>
<div>The HTML 5 spec defines the event-based drag-and-drop mechanism that
could cross the browser boundary. If a draggable element contains a URL,
dragging it out of the browser will only copy the URL value. However, in some
scenarios, we really want to download the data file from the specified URL,
instead of copying the value. Here we propose a way to allow dragging a
virtual file denoted by an URL out of the browser boundary.</div>
<div><br></div>
<div><span style="border-collapse:collapse">USE
CASES</span></div>
<div><span style="border-collapse:collapse"><br></span></div>
<div><span style="border-collapse:collapse">In order
to download the attachment from an Internet mail application, the user will
have to click the attachment link and a "save" dialog will pop up to let the
user select the destination folder. This will normally involves multiple
clicks. Native application, like Outlook, can let the user drag
attachments directly into the destination place, i.e. desktop, which is
really convenient. </span></div>
<div><span style="border-collapse:collapse"><br></span></div>
<div><span style="border-collapse:collapse">WORKAROUNDS</span></div>
<div><span style="border-collapse:collapse"><br></span></div>
<div><span style="border-collapse:collapse">Currently
there is no direct support in HTML 5 to support such dragging of the virtual
file. To work around this, a plugin with such capability has to be installed
and used.</span></div>
<div><span style="border-collapse:collapse"><br></span></div>
<div><span style="border-collapse:collapse">PROPOSAL</span></div>
<div><span style="border-collapse:collapse"><br></span></div>
<div><span style="border-collapse:collapse">
<div>We propose adding a specific format string to the DataTransfer object:
"DownloadURL". The data associated with the "DownloadURL" format should be
parsed similar to the "URL" format. When the drag ends in another application,
the remote file described in the associated data URL should be downloaded and
provided to the target application.</div>
<div><br></div>
<div>For example, here's how one can create a draggable image that results in
a file when dragged:</div>
<div><br></div>
<div>var dragTarget = document.createElement("img");</div>
<div>dragTarget.src = "<a href="http://example.com/example-attachment.gif" target="_blank">http://example.com/example-attachment.gif</a>";</div>
<div>document.body.insertBefore(dragTarget, document.body.firstChild);</div>
<div>dragTarget.addEventListener("dragstart", function(event) {</div>
<div> event.dataTransfer.setData("DownloadURL", "<a href="http://example.com/example-download-attachment" target="_blank">http://example.com/example-download-attachment</a>");</div>
<div>}, false);</div>
<div><br></div>
<div>
<div>Traditionally allowing the non-image file to be dragged out of the
browser is considered bad. The main danger here is that the user might
unknowingly drag a file that will auto-execute. To address this issue, the
browser needs to mark the dragged file to indicate that it is coming from the
Internet. With this zone marker, the user will be prompted with a security
warning dialog when the dropped file is launched. If a specific platform does
not support zone identifier marker, this feature should be turned off by
default.</div>
<div><br></div>
<div>We should consider allowing only http and https typed URL in the
associated data for the "DownloadURL" format. Should we further restrict the
download URL to the same origin?</div>
<div><br></div>
<div>If the filename is provided in the Content-Disposition header, it should
always be used. Otherwise, it is up to the browser to decide how the filename
is generated from the URL. But once it is chosen, it cannot be changed.</div>
<div><br></div>
<div>The drag-and-drop feedback might be decorated with the filename and the
domain from which the file is downloaded. However, the real filename might be
only available when we initiate the download and get back the response header.
To address this, we can download the response header after the drag is
initiated and then update the feedback image based on the filename retrieved
from the Content-Disposition header. This might not be possible for certain
platform because changing the drag meta-data might not be allowed.</div>
<div><br></div></div></span></div></div></div></blockquote></div>
</blockquote></div><br>