Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/yasu-s/blob-dl-js-sample

blob dl sample
https://github.com/yasu-s/blob-dl-js-sample

blob

Last synced: about 1 month ago
JSON representation

blob dl sample

Awesome Lists containing this project

README

        

# Overview

This is a minimum sample to save the text entered in textarea as a file.

# System requirements

* Node.js - 10.x
* Yarn - 1.12.x
* lite-server - 2.5.x

# Operation check

## 1. Download Sample

```
git clone [email protected]:yasu-s/blob-dl-js-sample.git
```

## 2. Installing packages

```
cd blob-dl-js-sample
yarn
```

## 3. Launch sample application

```
yarn start
```

## 4. Execution result

http://localhost:3000/

![blob_dl](https://user-images.githubusercontent.com/2668146/63091929-fce14000-bf9a-11e9-95d2-8c678ad7cb2d.gif)

# Sample source

```html


Blob Sample

function save() {
// get string from text area
const txt = document.getElementById('txt').value;
if (!txt) { return; }

// convert string to Blob
const blob = new Blob([txt], { type: 'text/plain' });

// a tag generation for download
const a = document.createElement('a');
a.href = URL.createObjectURL(blob);
a.download = 'sample.txt';
a.click();
};

Save Text


```