Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/yasu-s/blob-dl-js-sample
- Owner: yasu-s
- Created: 2019-08-14T07:56:44.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-05-06T13:02:34.000Z (over 1 year ago)
- Last Synced: 2024-10-29T22:08:34.202Z (3 months ago)
- Topics: blob
- Language: HTML
- Homepage:
- Size: 112 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
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
```