Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/m-avagyan/ublob
Helper module for working with files.
https://github.com/m-avagyan/ublob
base64 blob browser files javascript npm open-in-browser open-in-new-tab package react typescript yarn
Last synced: 8 days ago
JSON representation
Helper module for working with files.
- Host: GitHub
- URL: https://github.com/m-avagyan/ublob
- Owner: m-avagyan
- License: mit
- Created: 2022-08-07T09:28:06.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-10-16T09:09:30.000Z (about 1 year ago)
- Last Synced: 2023-10-17T03:01:16.978Z (about 1 year ago)
- Topics: base64, blob, browser, files, javascript, npm, open-in-browser, open-in-new-tab, package, react, typescript, yarn
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/ublob
- Size: 257 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ublob
Helper module for working with files.
## Installation
```bash
npm install ublob --save
```or
```bash
yarn add ublob
```## Usage
- `toBase64`: convert file to base 64 string
```typescript
import { toBase64 } from "ublob";toBase64(file)
.catch((error) => console.log(error))
.then((blob) =>
// set blob data...
);
```- `getFileType`: getting the file type
```typescript
import { getFileType, toBase64 } from "ublob";toBase64(file)
.catch((error) => console.log(error))
.then((blob) =>
const fileType = getFileType(blob);
// set file type to your state
);
```- `open`: open blob url in browser new tab
```typescript
import { open } from "ublob";const handleOpen = (blob) =>
open(blob, {
title: "Ublob PDF",
width: "100%",
height: "100%",
});
```- `getAvailableFileTypes`: getting the available file types
```typescript
import { getAvailableFileTypes } from "ublob";const availableFileTypes = getAvailableFileTypes();
// use this list where you want
```## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
## Author
**Martik Avagyan**
- Website: [martikavagyan.com](https://martikavagyan.com)
- Twitter: [@martikavagyan](https://twitter.com/martikavagyan)
- GitHub: [@m-avagyan](https://github.com/m-avagyan)## License
[MIT](https://choosealicense.com/licenses/mit/)