Skip to content

Latest commit

 

History

History
81 lines (61 loc) · 1.71 KB

README.md

File metadata and controls

81 lines (61 loc) · 1.71 KB

nuxt-secure-files

Embed images and download files securely via API requests


Table of contents

Main features

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

Setup

  1. Add nuxt-secure-files dependency to your project:
npm install nuxt-secure-files
  1. Add nuxt-secure-files module to nuxt.config.js:
export default {
  // ...other config options
  modules: ["nuxt-secure-files"];
}
  1. (Optional) TypeScript support. Add nuxt-secure-files to the types section of tsconfig.json:
{
  "compilerOptions": {
    "types": ["nuxt-secure-files"]
  }
}

Usage

  1. Make sure Axios is setup, so the Authorization request header is sent. Example:
const axiosPlugin: Plugin = ({ $axios }): void => {
  $axios.onRequest((config: AxiosRequestConfig): void => {
    config.headers.Authorization = 'Bearer XXXXXXXXXXXXXXXX'
  })
}

export default axiosPlugin
  1. Use $secDownload:
{
  methods: {
    downloadFile() {
        this.$secDownload('/api/file/xx', 'file_xx.pdf');
    }
  }
}

License

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