@strapi/provider-upload-local 4.0.0-next.9 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/lib/index.js +5 -9
  3. package/package.json +20 -20
package/README.md CHANGED
@@ -17,7 +17,7 @@ This provider has only one parameter: `sizeLimit`.
17
17
  }
18
18
  ```
19
19
 
20
- 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/developer-docs/latest/development/plugins/upload.html#configuration)
20
+ 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://docs.strapi.io/developer-docs/latest/plugins/upload.html#configuration)
21
21
 
22
22
  ## Resources
23
23
 
package/lib/index.js CHANGED
@@ -7,21 +7,17 @@
7
7
  // Public node modules.
8
8
  const fs = require('fs');
9
9
  const path = require('path');
10
- const { errors } = require('@strapi/plugin-upload');
10
+ const { PayloadTooLargeError } = require('@strapi/utils').errors;
11
11
 
12
12
  module.exports = {
13
13
  init({ sizeLimit = 1000000 } = {}) {
14
14
  const verifySize = file => {
15
15
  if (file.size > sizeLimit) {
16
- throw errors.entityTooLarge();
16
+ throw new PayloadTooLargeError();
17
17
  }
18
18
  };
19
- const configPublicPath = strapi.config.get(
20
- 'middleware.settings.public.path',
21
- strapi.config.paths.static
22
- );
23
19
 
24
- const uploadDir = path.resolve(strapi.dir, configPublicPath);
20
+ const publicDir = strapi.dirs.public;
25
21
 
26
22
  return {
27
23
  upload(file) {
@@ -30,7 +26,7 @@ module.exports = {
30
26
  return new Promise((resolve, reject) => {
31
27
  // write file in public/assets folder
32
28
  fs.writeFile(
33
- path.join(uploadDir, `/uploads/${file.hash}${file.ext}`),
29
+ path.join(publicDir, `/uploads/${file.hash}${file.ext}`),
34
30
  file.buffer,
35
31
  err => {
36
32
  if (err) {
@@ -46,7 +42,7 @@ module.exports = {
46
42
  },
47
43
  delete(file) {
48
44
  return new Promise((resolve, reject) => {
49
- const filePath = path.join(uploadDir, `/uploads/${file.hash}${file.ext}`);
45
+ const filePath = path.join(publicDir, `/uploads/${file.hash}${file.ext}`);
50
46
 
51
47
  if (!fs.existsSync(filePath)) {
52
48
  return resolve("File doesn't exist");
package/package.json CHANGED
@@ -1,48 +1,48 @@
1
1
  {
2
2
  "name": "@strapi/provider-upload-local",
3
- "version": "4.0.0-next.9",
3
+ "version": "4.0.0",
4
4
  "description": "Local provider for strapi upload",
5
- "homepage": "https://strapi.io",
6
5
  "keywords": [
7
6
  "upload",
8
7
  "strapi"
9
8
  ],
10
- "directories": {
11
- "lib": "./lib"
9
+ "homepage": "https://strapi.io",
10
+ "bugs": {
11
+ "url": "https://github.com/strapi/strapi/issues"
12
12
  },
13
- "main": "./lib",
14
- "strapi": {
15
- "isProvider": true
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git://github.com/strapi/strapi.git"
16
16
  },
17
+ "license": "SEE LICENSE IN LICENSE",
17
18
  "author": {
19
+ "name": "Strapi Solutions SAS",
18
20
  "email": "hi@strapi.io",
19
- "name": "Strapi team",
20
21
  "url": "https://strapi.io"
21
22
  },
22
23
  "maintainers": [
23
24
  {
24
- "name": "Strapi team",
25
+ "name": "Strapi Solutions SAS",
25
26
  "email": "hi@strapi.io",
26
27
  "url": "https://strapi.io"
27
28
  }
28
29
  ],
29
- "repository": {
30
- "type": "git",
31
- "url": "git://github.com/strapi/strapi.git"
30
+ "main": "./lib",
31
+ "directories": {
32
+ "lib": "./lib"
32
33
  },
33
- "peerDependencies": {
34
- "@strapi/plugin-upload": "^4.0.0"
34
+ "scripts": {
35
+ "test": "echo \"no tests yet\""
35
36
  },
36
- "bugs": {
37
- "url": "https://github.com/strapi/strapi/issues"
37
+ "dependencies": {
38
+ "@strapi/utils": "4.0.0"
38
39
  },
39
40
  "engines": {
40
41
  "node": ">=12.x.x <=16.x.x",
41
42
  "npm": ">=6.0.0"
42
43
  },
43
- "license": "SEE LICENSE IN LICENSE",
44
- "scripts": {
45
- "test": "echo \"no tests yet\""
44
+ "strapi": {
45
+ "isProvider": true
46
46
  },
47
- "gitHead": "231263a3535658bab1e9492c6aaaed8692d62a53"
47
+ "gitHead": "b181702f0202b2c6d645d42b195a831f25cd0b03"
48
48
  }