Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/dogchef-be/nuxt-secure-files

🔐 Embed images and download files securely via API requests
https://github.com/dogchef-be/nuxt-secure-files

ajax api-requests base64 download nuxt nuxt-module nuxtjs-ts nuxtjs-typescript typescript-support

Last synced: about 1 month ago
JSON representation

🔐 Embed images and download files securely via API requests

Awesome Lists containing this project

README

        


nuxt-secure-files



Embed images and download files securely via API requests





## Table of contents
- [Main features](#main-features)
- [Setup](#setup)
- [Usage](#usage)
- [License](#license)

## Main features

- Download Base64 files
- Directive for embedding images (WIP)
- TypeScript support

## Setup

1. Add `nuxt-secure-files` dependency to your project:

```bash
npm install nuxt-secure-files
```

2. Add `nuxt-secure-files` module to `nuxt.config.js`:

```js
export default {
// ...other config options
modules: ["nuxt-secure-files"];
}
```

3. (Optional) TypeScript support. Add `nuxt-secure-files` to the `types` section of `tsconfig.json`:

```json
{
"compilerOptions": {
"types": ["nuxt-secure-files"]
}
}
```

## Usage

1. Make sure Axios is setup, so the Authorization request header is sent. Example:

```ts
const axiosPlugin: Plugin = ({ $axios }): void => {
$axios.onRequest((config: AxiosRequestConfig): void => {
config.headers.Authorization = 'Bearer XXXXXXXXXXXXXXXX'
})
}

export default axiosPlugin
```

2. Use `$secDownload`:

```ts
{
methods: {
downloadFile() {
this.$secDownload('/api/file/xx', 'file_xx.pdf');
}
}
}
```

## License

See the LICENSE file for license rights and limitations (MIT).