Skip to content

Instantly share code, notes, and snippets.

function callAsync(fn) {
// get iterator
var iterator = fn();
// used as a callback to currently yielded functions
function next() {
// get next function
var current = iterator.next();
// recursion exit condition
@stormoz
stormoz / gist:93eaa11b846ae413eaf374482842a72d
Last active March 8, 2019 02:19
Node JS: send binary file as multiform data
var formData = {
'myfile_key': {
value: <Buffer object>
options: {
filename: 'image_file'
}
}
};
@stormoz
stormoz / read data to stream
Created July 25, 2019 13:19
read data to stream
import http from 'http';
import axios from 'axios';
http.createServer(async function (req, res) {
const responseStream = await axios({
method: 'get',
url: 'http://blob.file.storage/filepath',
responseType: 'stream'
});
@stormoz
stormoz / axios_get_pipe_zip.js
Created July 25, 2019 13:29 — forked from bhuizi/axios_get_pipe_zip.js
axios get request w/ piping
const axios = require('axios');
const fs = require('fs');
const url = <path_to_file>
axios({
method: 'get',
url: url,
responseType:'stream'
})
.then(res => {
res.data.pipe(fs.createWriteStream('new.zip'));