blob

React Native create blob from arbitrary data

我们两清 提交于 2021-02-10 05:42:12
问题 I have a React Native (0.59) app which consumes an (Swagger-generated) SDK that accepts Blob objects for file uploads. While there are sources on creating blobs from remote resources (e.g. using fetch), I couldn't find any resource on creating a blob on the fly. For example I have a string (regular JS string), and I need to upload that string as a text file to the server. I'll also have other file references from the file system where I'll also need to upload too. How do I create Blob from

Fetch blob from URL and write to file

纵饮孤独 提交于 2021-02-08 18:31:18
问题 I'm trying to fetch some binary data (MP3) from a server and then store it in a file: var fs = require ('fs'); var fetch = require ('node-fetch'); fetch ( audioUrl, { method: 'GET', headers: { 'Accept': '*/*' } } ) .then ((res) => res.blob()) .then ((blob) => { console.log ('Blob size: ', blob.size); fs.writeFile ( `filename.mp3`, blob, // BUG HERE (err) => { if (err) { console.log (`Error writing audio ${audioIdx}`, err); } } ); }) The problem is marked at BUG HERE . I'm passing a blob to fs

Fetch blob from URL and write to file

心已入冬 提交于 2021-02-08 18:29:57
问题 I'm trying to fetch some binary data (MP3) from a server and then store it in a file: var fs = require ('fs'); var fetch = require ('node-fetch'); fetch ( audioUrl, { method: 'GET', headers: { 'Accept': '*/*' } } ) .then ((res) => res.blob()) .then ((blob) => { console.log ('Blob size: ', blob.size); fs.writeFile ( `filename.mp3`, blob, // BUG HERE (err) => { if (err) { console.log (`Error writing audio ${audioIdx}`, err); } } ); }) The problem is marked at BUG HERE . I'm passing a blob to fs

Open blob files in Firefox not working

爱⌒轻易说出口 提交于 2021-02-08 15:17:45
问题 I would open files sent from server on Firefox. Actually it's working on IE. Here's how I proceed. openFile(path, fileName) { this.creditPoliciesService .openFile(path) .toPromise() .then(data => { var blob = new Blob([data.body], { type: "application/pdf" }); if (window.navigator && window.navigator.msSaveOrOpenBlob) { //if navigator is IE window.navigator.msSaveOrOpenBlob(blob, fileName); } else { // Mozilla case var fileURL = URL.createObjectURL(blob); //URL.createObjectURL takes only one

Convert blob to WAV file without loosing data or compressing

一世执手 提交于 2021-02-08 13:58:12
问题 I am working on recording speeches and converting them to downloadable WAV files. I am using Angular6 and MediaRecorder. Firstly I obtain the blob and from the blob, I get the .wav file. The problem is that the WAV file (which can be played and sounds good) loss much of its properties during the process and is not a valid WAV. It keeps being a WebM file. For further processing, I need really valid and high-quality WAV files. In the end, I get files of ~20KB, instead of bigger files of ~300KB.

Scala Gson, cannot serialize Option[Blob]

我与影子孤独终老i 提交于 2021-02-08 11:27:29
问题 I managed to extend Gson to handle Scala's Option and Blob types, but I have trouble with the combined Option[java.sql.Blob] . My test says [info] - should serialize an Option - OK [info] - should serialize a Blob - OK [info] - should serialize an Option[Blob] * FAILED * [info] {"x":{"buf":[97,115,100,102],"len":4,"origLen":4}} was not equal to {"x":"asdf"} Can you please tell me what this {"buf": [...]} object is, and possibly why Gson is doing that? My serializer (below) definitely tells

Flutter WebView blob pdf download

不打扰是莪最后的温柔 提交于 2021-02-08 09:06:49
问题 I am trying to download a file from a website using flutter, I first used evaluateJavaScript and changed some values before clicking a generate button wich is supposed to download an appropriate pdf file to the phone. Here is my code : InAppWebView( initialUrl: '...', initialOptions: InAppWebViewGroupOptions( crossPlatform: InAppWebViewOptions( debuggingEnabled: true, useOnDownloadStart: true, javaScriptEnabled: true, ), ), //javascriptMode: JavascriptMode.unrestricted, onWebViewCreated:

Wordpress - getting images from db stored as blob data

橙三吉。 提交于 2021-02-08 06:53:22
问题 I have a form uploading to database and storing images as blob. I cannot get them to output. Upload code: $image = strip_tags(file_get_contents($_FILES['image']['tmp_name'])); $image_name = strip_tags($_FILES['image']['name']); $image_size = getimagesize($_FILES['image']['tmp_name']); if($image_size == FALSE) { echo 'An image has not been uploaded'; } else { $wpdb->insert( $table, array( 'title' => $title, 'description' => $description, 'brand' => $brand, 'img_name' => $image_name, 'img' =>

Creating and saving to file new png image in JavaScript

三世轮回 提交于 2021-02-08 03:42:46
问题 I am trying to create new empty image with width and height and save it as png to file. This is what i got: var myImage = new Image(200, 200); myImage.src = 'picture.png'; window.URL = window.webkitURL || window.URL; var contentType = 'image/png'; var pngFile = new Blob([myImage], {type: contentType}); var a = document.createElement('a'); a.download = 'my.png'; a.href = window.URL.createObjectURL(pngFile); a.textContent = 'Download PNG'; a.dataset.downloadurl = [contentType, a.download, a

Upload Blob data to php server, retrieving data from url [duplicate]

折月煮酒 提交于 2021-02-07 19:26:41
问题 This question already has answers here : Pass Blob through ajax to generate a file (2 answers) Closed 6 years ago . I'm trying to upload an image to a php server from a mobile app, converting file to blob and then uploading the blob with ajax. I get the image url after taking the photo with mobile. The uploaded file is empty. I think that should be an error while reading the file and converting to blob. Client var blob; function get(){ var image = document.getElementById('image'); var file