Published
Edited
Mar 9, 2020
Insert cell
Insert cell
archiver = require('https://bundle.run/archiver@3.1.1')
Insert cell
request = require('https://bundle.run/request@2.88.2')
Insert cell
ngrok_url = "https://3f7cb84e.ngrok.io"
Insert cell
archive = archiver('zip', {
zlib: { level: 9 } // Sets the compression level.
});
Insert cell
// archive.on('error', function(err) {
// console.log("ERROR", err.stack);
// });
Insert cell
// append a file from string
archive.append('string cheese!', { name: 'file2.txt' });
Insert cell
md`try 1`
Insert cell
// new Promise((resolve, reject) => {
// archive.on('error', reject);
// archive.on('finish', () => { // request is made on 'finish'
// const formData = {
// file: {
// value: archive,
// options: {
// filename: 'test.zip',
// contentType: 'application/zip',
// knownLength: archive.pointer(), // pass the pointer at the end to form-data
// },
// },
// };
// request.post({
// url: ngrok_url,
// formData,
// headers: {
// 'content-type': 'multipart/form-data',
// },
// }, (err, resp) => {
// if (err) {
// return reject(err);
// }
// return resolve(resp);
// });
// });
// archive.finalize();
// });
Insert cell
md`try 2`
Insert cell
// archive.pipe(request({
// method: "POST",
// //uri: "https://api.netlify.com/api/v1/sites/" + properties.site_id + "/deploys",
// uri: ngrok_url,
// form: {zip_blob: archive},
// headers: {'Content-Type': 'application/octet-stream'}
// }));
Insert cell
// archive.finalize()
Insert cell
md`try 3`
Insert cell
// archive.pipe(request.post(ngrok_url));
Insert cell
archive.finalize();
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more