# strapi-provider-upload-local-custom-path

> Local provider for strapi upload

Latest version **1.0.7** (published 2020-12-01) · SEE LICENSE IN LICENSE license · 0 weekly downloads

## Install

```sh
npm install strapi-provider-upload-local-custom-path
pnpm add strapi-provider-upload-local-custom-path
yarn add strapi-provider-upload-local-custom-path
bun add strapi-provider-upload-local-custom-path
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2020-12-01 |
| First published | 2020-12-01 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN LICENSE |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10.16.0 <=14.x.x |
| Dependencies | 0 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Niall Cargill |
| Maintainers | ikhnaton |
| Keywords | upload, strapi, custom |

## Links

- npm: https://www.npmjs.com/package/strapi-provider-upload-local-custom-path
- Repository: https://github.com/ikhnaton/strapi-provider-upload-local-custom-path
- Homepage: https://github.com/ikhnaton/strapi-provider-upload-local-custom-path#readme
- Issues: https://github.com/ikhnaton/strapi-provider-upload-local-custom-path/issues
- npm.io page: https://npm.io/package/strapi-provider-upload-local-custom-path

## Recent versions

- 1.0.7 (latest) — 2020-12-01
- 1.0.6 — 2020-12-01
- 1.0.5 — 2020-12-01
- 1.0.4 — 2020-12-01
- 1.0.3 — 2020-12-01
- 1.0.2 — 2020-12-01
- 1.0.1 — 2020-12-01
- 1.0.0 — 2020-12-01

## README

# strapi-provider-upload-local-custom-path

## Configurations

This provider has two parameters: `path` and `sizeLimit`.

**Example**

`./config/plugins.js`

```js
module.exports = ({ env }) => ({
  upload: {
    provider: 'local-custom-path',
    providerOptions: {
      path: env('UPLOADS_PATH') || '.tmp/media',
      sizeLimit: 100000
    },
  },
});
```

The `sizeLimit` parameter must be a number. Be aware that the unit is in bytes, and the default is 1000000. When setting this value high, you should make sure to also configure the body parser middleware `maxFileSize` so the file can be sent and processed. Read more [here](https://strapi.io/documentation/v3.x/plugins/upload.html#configuration)

**Note**

You will likely need to add `./middlewares/upload/index.js`

```js
'use strict';

const { resolve } = require('path');
const range = require('koa-range');
const koaStatic = require('koa-static');
const get = require('lodash/get')

module.exports = strapi => ({
  initialize() {
    const configPublicPath = strapi.config.get(
      'middleware.settings.public.path',
      strapi.config.paths.static
    );

    const staticDir = get(strapi, "config.plugins.upload.providerOptions.path", resolve(strapi.dir, configPublicPath));

    strapi.app.on('error', err => {
      if (err.code === 'EPIPE') {
        return;
      }

      strapi.app.onerror(err);
    });

    strapi.router.get('/uploads/(.*)', range, koaStatic(staticDir, { defer: true }));
  },
});
```

## Resources

- [License](LICENSE)

## Links

- [Strapi website](http://strapi.io/)
- [Strapi community on Slack](http://slack.strapi.io)
- [Strapi news on Twitter](https://twitter.com/strapijs)

---
_Source: https://npm.io/package/strapi-provider-upload-local-custom-path · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
