data-url

Downloading file from DataURL in JavaScript

a 夏天 提交于 2019-12-03 00:29:20
From this string we get from DataURL, what's the best way to download this as a file? So far what I got was using a basic window.open("myDataURL"); , but I'm not able to change the file name in this way. window.open('data:application/msword;base64,0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAA PgADAP7/CQAGAAAAAAAAAAAAAAACAAAANQAAAAAAA AAAEAAANwAAAAIAAAD+////AAAAADQAAABsAA/', '_blank','height=300,width=400'); I was wondering if there's any way to handle this data properly. you can add a download attribute to the anchor element. sample: <a download="abcd.zip" href="data:application/stream;base64,MIIDhTCCAvKg.

Trying to save canvas PNG data url to disk with HTML5 filesystem, but when I retrieve as URL, it's invalid

半城伤御伤魂 提交于 2019-12-02 18:32:33
I get the base64-encoded image form the canvas as: var dataURL = canvas.toDataURL( "image/png" ); Then I turn it into data like this: //Remove the beginning identifier and use Chrome/Firefox?safari built int base64Decoder var data = atob( dataURL.substring( "data:image/png;base64,".length ) ); Then I write it to the filesystem via: event.createWriter( function(writerEvent) { //The success handler writerEvent.onwriteend = function(finishEvent) { ... }; //Error handler writerEvent.onerror = settings.error; // Create a new Blob var blob = new Blob( [ data ], { type: "image/png" } ); //Write it

Can I store image on Firebase as file, instead of a data:url?

笑着哭i 提交于 2019-12-02 06:04:41
问题 I want to store image on firebase and want to use it somewhere. I went through this SO post and tried this demo. It stores images as data:url format. But I want to upload and store images as physical file so I can use it further, something like this url http://example.com/some_image.png Can I achieve this with Firebase? 回答1: No. The Firebase API currently does not support storing files outside of its database. Update: at Google I/O 2016 Firebase added Firebase Storage to its offering, which

Can I store image on Firebase as file, instead of a data:url?

五迷三道 提交于 2019-12-02 00:24:01
I want to store image on firebase and want to use it somewhere. I went through this SO post and tried this demo . It stores images as data:url format. But I want to upload and store images as physical file so I can use it further, something like this url http://example.com/some_image.png Can I achieve this with Firebase? No. The Firebase API currently does not support storing files outside of its database. Update: at Google I/O 2016 Firebase added Firebase Storage to its offering, which is a service dedicated to storing files. 来源: https://stackoverflow.com/questions/30054575/can-i-store-image

How do I extract a portion of an image in canvas and use it as background image for a div?

孤人 提交于 2019-12-01 21:08:59
This is how my code looks: document.addEventListener('DOMContentLoaded', function () { var canvas = document.querySelector('canvas'); var ctx = canvas.getContext("2d"); var imageData = ctx.getImageData(0, 0, 300, 300); var tile = { 'id': 1, 'data': imageData, 'dataUrl': imageData.toDataUrl() }; var div = document.createElement('div'); div.classList.add('tile'); grid.appendChild(div); div.style.backgroundImage = ('url(' + tile.dataUrl + ')'); }); I'm trying to extract portion of the image on canvas, from (0,0) with height and width 300px, and convert that imageData object into a dataUrl to be

Convert Data-URL to BufferedImage

风流意气都作罢 提交于 2019-11-30 13:13:02
问题 I have a Data-URL from an image file and have to pass it through to another function. Along this path from Data-URL to the BufferedImage it needs to be a byteArray. my approach was the following: String dataUrl; byte[] imageData = dataUrl.getBytes(); // pass the byteArray along the path // create BufferedImage from byteArray BufferedImage inputImage = ImageIO.read(new ByteArrayInputStream(imageData)); // If the picture is null, then throw an unsupported image exception. if (inputImage == null

iPhone Open DATA: Url In Safari

偶尔善良 提交于 2019-11-30 07:10:25
I have a Data: URL (see: http://en.wikipedia.org/wiki/Data_URI_scheme ) (as a NSString) and I want to open it in Safari. How would you accomplish this (I tried openURL:.) Example: data:text/html;base64,(Some Base64 Encoded Data Here) ddoughty In iPhone OS 2.2.1 and 5.0.1, in both the simulator and on a device, opening a data: url works perfectly in a UIWebView but using openURL does precisely nothing. And Safari will gladly, and properly, render such an URL if you are willing to type one into the navigation bar, so this is clearly a problem with sharedApplication openURL , not with Safari. If

Convert Data-URL to BufferedImage

爱⌒轻易说出口 提交于 2019-11-30 06:49:16
I have a Data-URL from an image file and have to pass it through to another function. Along this path from Data-URL to the BufferedImage it needs to be a byteArray. my approach was the following: String dataUrl; byte[] imageData = dataUrl.getBytes(); // pass the byteArray along the path // create BufferedImage from byteArray BufferedImage inputImage = ImageIO.read(new ByteArrayInputStream(imageData)); // If the picture is null, then throw an unsupported image exception. if (inputImage == null) { throw new UnknownImageFormatException(); } The problem is, it always throws the

jQuery and Canvas.toDataURL

落花浮王杯 提交于 2019-11-29 16:15:55
I'm working on a script, and a small part of that involves taking a canvas and converting it to a downloadable image. To do this, I do: var thumb_jpeg = thumbnail.toDataURL("image/jpeg"); $("#" + options.dest).attr('src',thumb_jpeg); ...where thumbnail is a canvas tag and options.dest is the name of an img id. This code works perfectly in Chrome, but when I try it in Firefox, Firebug throws up this error: Security error" code: "1000 var thumb_jpeg = thumbnail.toDataURL("image/jpeg"); I would link to the whole script, but everything is hosted on my computer. Does anyone have any idea what this

Streaming PDF into iframe using dataurl - works only in Chrome

允我心安 提交于 2019-11-29 15:37:12
The following works in Chrome, but the iframe content is blank in Firefox 15 and IE 9. <html> <head></head> <body> <p>this n that</p> <iframe type="application/pdf" width="95%" height="95%" src="data:application/pdf;base64,<?php echo base64_encode(file_get_contents('memlist.pdf'));?>"> Oops, you have no support for iframes. </iframe> <p>this n that</p> </body> </html> The problem seems to be the dataurl. If I change it to simply src="memlist.pdf" then it works everywhere. The PDF size is 75kb. Is there some (current) browser limitations with dataurls? (I'm trying to avoid the call back to the