@akemona-org/strapi-plugin-upload 3.7.0 → 3.7.2

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 (88) hide show
  1. package/admin/src/components/BrowseAssets/index.js +8 -8
  2. package/admin/src/components/Card/index.js +1 -1
  3. package/admin/src/components/CardControl/index.js +1 -1
  4. package/admin/src/components/CardErrorMessage/index.js +1 -1
  5. package/admin/src/components/CardImgWrapper/index.js +1 -1
  6. package/admin/src/components/CardTitle/index.js +1 -1
  7. package/admin/src/components/CheckControl/index.js +3 -3
  8. package/admin/src/components/DragLayer/index.js +1 -1
  9. package/admin/src/components/DropdownButton/index.js +1 -1
  10. package/admin/src/components/Duration/utils/formatDuration.js +1 -1
  11. package/admin/src/components/EditForm/FileDetailsBox.js +1 -1
  12. package/admin/src/components/EditForm/SizeBox.js +1 -1
  13. package/admin/src/components/EditForm/index.js +6 -6
  14. package/admin/src/components/EditForm/utils/isImageType.js +1 -1
  15. package/admin/src/components/EditForm/utils/isVideoType.js +1 -1
  16. package/admin/src/components/FileIcon/index.js +1 -1
  17. package/admin/src/components/FiltersList/utils/formatFilter.js +1 -1
  18. package/admin/src/components/FiltersPicker/FiltersCard/FilterInput.js +1 -1
  19. package/admin/src/components/FiltersPicker/FiltersCard/index.js +2 -2
  20. package/admin/src/components/FiltersPicker/FiltersCard/init.js +1 -1
  21. package/admin/src/components/FiltersPicker/FiltersCard/reducer.js +1 -7
  22. package/admin/src/components/FiltersPicker/index.js +2 -2
  23. package/admin/src/components/FiltersPicker/utils/formatFilter.js +1 -1
  24. package/admin/src/components/InputFileModal/index.js +2 -2
  25. package/admin/src/components/InputMedia/index.js +7 -7
  26. package/admin/src/components/IntlText/index.js +1 -1
  27. package/admin/src/components/List/index.js +3 -3
  28. package/admin/src/components/ListEmpty/index.js +2 -2
  29. package/admin/src/components/ListEmpty/utils/generateRows.js +1 -1
  30. package/admin/src/components/ListModal/index.js +2 -2
  31. package/admin/src/components/ModalNavWrapper/index.js +2 -2
  32. package/admin/src/components/ModalTab/index.js +1 -1
  33. package/admin/src/components/SelectedAssets/DraggableCard.js +1 -1
  34. package/admin/src/components/SelectedAssets/SortableList.js +4 -4
  35. package/admin/src/components/SortList/Wrapper.js +1 -1
  36. package/admin/src/components/SortList/index.js +1 -1
  37. package/admin/src/components/SortListItem/Wrapper.js +1 -1
  38. package/admin/src/components/SortPicker/index.js +3 -3
  39. package/admin/src/components/UploadForm/index.js +2 -2
  40. package/admin/src/components/UploadList/ListTitle.js +1 -1
  41. package/admin/src/components/UploadList/index.js +1 -1
  42. package/admin/src/components/VideoPreview/index.js +2 -9
  43. package/admin/src/containers/HomePage/HomePageContent/index.js +4 -4
  44. package/admin/src/containers/HomePage/index.js +10 -10
  45. package/admin/src/containers/HomePage/reducer.js +11 -9
  46. package/admin/src/containers/HomePage/utils/generateParamsFromQuery.js +1 -1
  47. package/admin/src/containers/HomePage/utils/generateStringFromParams.js +2 -2
  48. package/admin/src/containers/HomePage/utils/getHeaderLabel.js +1 -1
  49. package/admin/src/containers/Initializer/index.js +1 -1
  50. package/admin/src/containers/InputModalStepper/InputModalStepper.js +6 -4
  51. package/admin/src/containers/InputModalStepper/Search.js +1 -1
  52. package/admin/src/containers/InputModalStepper/index.js +1 -1
  53. package/admin/src/containers/InputModalStepperProvider/index.js +17 -17
  54. package/admin/src/containers/InputModalStepperProvider/init.js +1 -1
  55. package/admin/src/containers/InputModalStepperProvider/reducer.js +10 -10
  56. package/admin/src/containers/ModalStepper/index.js +16 -15
  57. package/admin/src/containers/ModalStepper/init.js +1 -1
  58. package/admin/src/containers/ModalStepper/reducer.js +15 -18
  59. package/admin/src/containers/SettingsPage/init.js +1 -1
  60. package/admin/src/icons/BrokenFile/index.js +1 -1
  61. package/admin/src/icons/Cloud/index.js +1 -1
  62. package/admin/src/icons/DoubleFile/index.js +1 -1
  63. package/admin/src/icons/Download/index.js +1 -1
  64. package/admin/src/icons/File/index.js +1 -1
  65. package/admin/src/index.js +1 -1
  66. package/admin/src/pluginId.js +1 -1
  67. package/admin/src/utils/canDownloadFile.js +1 -1
  68. package/admin/src/utils/compactParams.js +2 -2
  69. package/admin/src/utils/createMatrix.js +1 -1
  70. package/admin/src/utils/createNewFilesToDownloadArray.js +3 -3
  71. package/admin/src/utils/createNewFilesToUploadArray.js +1 -1
  72. package/admin/src/utils/formatFileForEditing.js +1 -1
  73. package/admin/src/utils/formatFilters.js +1 -1
  74. package/admin/src/utils/getFileModelTimestamps.js +1 -1
  75. package/admin/src/utils/getFilesToDownload.js +2 -2
  76. package/admin/src/utils/getRequestUrl.js +1 -1
  77. package/admin/src/utils/getTrad.js +1 -1
  78. package/admin/src/utils/getType.js +1 -1
  79. package/admin/src/utils/getYupError.js +5 -8
  80. package/admin/src/utils/unformatBytes.js +1 -1
  81. package/admin/src/utils/urlYupSchema.js +1 -1
  82. package/config/functions/bootstrap.js +10 -8
  83. package/config/schema.graphql.js +2 -2
  84. package/errors.js +3 -3
  85. package/middlewares/upload/index.js +2 -2
  86. package/package.json +5 -5
  87. package/services/image-manipulation.js +11 -14
  88. package/utils/file.js +3 -3
@@ -13,7 +13,7 @@ const reducer = (state, action) => {
13
13
  switch (action.type) {
14
14
  case 'ADD_FILES_TO_UPLOAD':
15
15
  return state
16
- .update('filesToUpload', list =>
16
+ .update('filesToUpload', (list) =>
17
17
  list
18
18
  .concat(fromJS(createNewFilesToUploadArray(action.filesToUpload)))
19
19
  .map((data, index) => data.set('originalIndex', index))
@@ -21,7 +21,7 @@ const reducer = (state, action) => {
21
21
  .update('currentStep', () => action.nextStep);
22
22
  case 'ADD_URLS_TO_FILES_TO_UPLOAD':
23
23
  return state
24
- .update('filesToUpload', list =>
24
+ .update('filesToUpload', (list) =>
25
25
  list
26
26
  .concat(
27
27
  fromJS(createNewFilesToDownloadArray(state.get('filesToDownload'), list.toJS()))
@@ -31,8 +31,8 @@ const reducer = (state, action) => {
31
31
  .update('currentStep', () => action.nextStep)
32
32
  .update('filesToDownload', () => fromJS([]));
33
33
  case 'CLEAN_FILES_ERROR':
34
- return state.update('filesToUpload', list =>
35
- list.map(data => {
34
+ return state.update('filesToUpload', (list) =>
35
+ list.map((data) => {
36
36
  if (data.get('tempId')) {
37
37
  return data;
38
38
  }
@@ -41,8 +41,8 @@ const reducer = (state, action) => {
41
41
  })
42
42
  );
43
43
  case 'FILE_DOWNLOADED':
44
- return state.updateIn(['filesToUpload'], list => {
45
- return list.map(file => {
44
+ return state.updateIn(['filesToUpload'], (list) => {
45
+ return list.map((file) => {
46
46
  if (file.get('tempId') === action.fileTempId) {
47
47
  return file.update('isDownloading', () => false).update('file', () => action.blob);
48
48
  }
@@ -70,8 +70,8 @@ const reducer = (state, action) => {
70
70
  case 'ON_SUBMIT_EDIT_EXISTING_FILE':
71
71
  return state.updateIn(['fileToEdit', 'isUploading'], () => true);
72
72
  case 'REMOVE_FILE_TO_UPLOAD':
73
- return state.update('filesToUpload', list => {
74
- return list.filter(data => data.get('originalIndex') !== action.fileIndex);
73
+ return state.update('filesToUpload', (list) => {
74
+ return list.filter((data) => data.get('originalIndex') !== action.fileIndex);
75
75
  });
76
76
  case 'RESET_FILE_TO_EDIT':
77
77
  return state.update('fileToEdit', () => null);
@@ -81,8 +81,8 @@ const reducer = (state, action) => {
81
81
  return state.updateIn(['fileToEdit', 'file'], () => fromJS(action.blob));
82
82
  }
83
83
  case 'SET_FILE_ERROR':
84
- return state.update('filesToUpload', list => {
85
- return list.map(data => {
84
+ return state.update('filesToUpload', (list) => {
85
+ return list.map((data) => {
86
86
  if (data.get('originalIndex') === action.fileIndex) {
87
87
  return data
88
88
  .set('isUploading', false)
@@ -94,8 +94,8 @@ const reducer = (state, action) => {
94
94
  });
95
95
  });
96
96
  case 'SET_FILE_TO_DOWNLOAD_ERROR':
97
- return state.update('filesToUpload', list => {
98
- return list.map(file => {
97
+ return state.update('filesToUpload', (list) => {
98
+ return list.map((file) => {
99
99
  if (file.get('tempId') === action.fileTempId) {
100
100
  return file
101
101
  .update('isDownloading', () => false)
@@ -114,12 +114,9 @@ const reducer = (state, action) => {
114
114
  .updateIn(['fileToEdit', 'errorMessage'], () => action.errorMessage)
115
115
  .updateIn(['fileToEdit', 'isUploading'], () => false);
116
116
  case 'SET_FILES_UPLOADING_STATE':
117
- return state.update('filesToUpload', list =>
118
- list.map(data =>
119
- data
120
- .set('isUploading', true)
121
- .set('hasError', false)
122
- .set('errorMessage', null)
117
+ return state.update('filesToUpload', (list) =>
118
+ list.map((data) =>
119
+ data.set('isUploading', true).set('hasError', false).set('errorMessage', null)
123
120
  )
124
121
  );
125
122
 
@@ -1,4 +1,4 @@
1
- const init = initialState => {
1
+ const init = (initialState) => {
2
2
  return initialState;
3
3
  };
4
4
 
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- const BrokenFile = props => {
3
+ const BrokenFile = (props) => {
4
4
  return (
5
5
  <svg
6
6
  width="48px"
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- const Cloud = props => {
3
+ const Cloud = (props) => {
4
4
  return (
5
5
  <svg width="53" height="42" xmlns="http://www.w3.org/2000/svg" {...props}>
6
6
  <defs>
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- const DoubleFile = props => {
3
+ const DoubleFile = (props) => {
4
4
  return (
5
5
  <svg width="21" height="21" xmlns="http://www.w3.org/2000/svg" {...props}>
6
6
  <defs>
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- const Download = props => {
3
+ const Download = (props) => {
4
4
  return (
5
5
  <svg width="16" height="17" xmlns="http://www.w3.org/2000/svg" {...props}>
6
6
  <defs>
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- const File = props => {
3
+ const File = (props) => {
4
4
  return (
5
5
  <svg width="21" height="25" xmlns="http://www.w3.org/2000/svg" {...props}>
6
6
  <defs>
@@ -19,7 +19,7 @@ import trads from './translations';
19
19
  import pluginId from './pluginId';
20
20
  import { getTrad } from './utils';
21
21
 
22
- export default strapi => {
22
+ export default (strapi) => {
23
23
  const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
24
24
  const icon = pluginPkg.strapi.icon;
25
25
  const name = pluginPkg.strapi.name;
@@ -1,5 +1,5 @@
1
1
  import pluginPkg from '../../package.json';
2
2
 
3
- const pluginId = pluginPkg.name.replace(/^strapi-plugin-/i, '');
3
+ const pluginId = pluginPkg.name.replace(/^@akemona-org\/strapi-plugin-/i, '');
4
4
 
5
5
  export default pluginId;
@@ -1,3 +1,3 @@
1
- const canDownloadFile = fileURL => typeof fileURL === 'string' && fileURL.startsWith('/');
1
+ const canDownloadFile = (fileURL) => typeof fileURL === 'string' && fileURL.startsWith('/');
2
2
 
3
3
  export default canDownloadFile;
@@ -1,9 +1,9 @@
1
1
  import { omitBy } from 'lodash';
2
2
 
3
- const compactParams = params =>
3
+ const compactParams = (params) =>
4
4
  omitBy(
5
5
  params,
6
- param =>
6
+ (param) =>
7
7
  (typeof param === 'string' && param === '') ||
8
8
  (Array.isArray(param) && param.length === 0) ||
9
9
  param === null ||
@@ -1,4 +1,4 @@
1
- const createMatrix = refArray => {
1
+ const createMatrix = (refArray) => {
2
2
  const maxNumberOfColumns = 4;
3
3
  const matrix = [];
4
4
 
@@ -1,11 +1,11 @@
1
1
  import axios from 'axios';
2
2
  import { isEmpty } from 'lodash';
3
3
 
4
- const getTempsIds = alreadyUploadedFiles => {
5
- return [...new Set([0, ...alreadyUploadedFiles.map(file => file.tempId).filter(id => !!id)])];
4
+ const getTempsIds = (alreadyUploadedFiles) => {
5
+ return [...new Set([0, ...alreadyUploadedFiles.map((file) => file.tempId).filter((id) => !!id)])];
6
6
  };
7
7
 
8
- const getMax = arr => {
8
+ const getMax = (arr) => {
9
9
  return Math.max.apply(Math, arr) + 1;
10
10
  };
11
11
 
@@ -1,4 +1,4 @@
1
- const createNewFilesToUploadArray = filesObject => {
1
+ const createNewFilesToUploadArray = (filesObject) => {
2
2
  return Object.keys(filesObject).reduce((acc, current) => {
3
3
  const currentFile = filesObject[current];
4
4
  const abortController = new AbortController();
@@ -1,6 +1,6 @@
1
1
  import { pick } from 'lodash';
2
2
 
3
- const formatFileForEditing = file => {
3
+ const formatFileForEditing = (file) => {
4
4
  const abortController = new AbortController();
5
5
 
6
6
  return {
@@ -1,4 +1,4 @@
1
- const formatFilters = params => {
1
+ const formatFilters = (params) => {
2
2
  const indexOfFileFilterContains = params.indexOf('mime_contains=file');
3
3
  const indexOfFileFilterNContains = params.indexOf('mime_ncontains=file');
4
4
  let paramsToReturn = params;
@@ -1,7 +1,7 @@
1
1
  import { get } from 'lodash';
2
2
  import pluginId from '../pluginId';
3
3
 
4
- const getFileModelTimestamps = plugins => {
4
+ const getFileModelTimestamps = (plugins) => {
5
5
  const timestamps = get(plugins, [pluginId, 'fileModel', 'options', 'timestamps']);
6
6
 
7
7
  // All connectors must initialise the "timestamps" option as a tuple
@@ -1,5 +1,5 @@
1
- const getFilesToDownload = files => {
2
- return files.filter(file => file.isDownloading === true);
1
+ const getFilesToDownload = (files) => {
2
+ return files.filter((file) => file.isDownloading === true);
3
3
  };
4
4
 
5
5
  export default getFilesToDownload;
@@ -1,5 +1,5 @@
1
1
  import pluginId from '../pluginId';
2
2
 
3
- const getRequestUrl = path => `/${pluginId}/${path}`;
3
+ const getRequestUrl = (path) => `/${pluginId}/${path}`;
4
4
 
5
5
  export default getRequestUrl;
@@ -1,5 +1,5 @@
1
1
  import pluginId from '../pluginId';
2
2
 
3
- const getTrad = id => `${pluginId}.${id}`;
3
+ const getTrad = (id) => `${pluginId}.${id}`;
4
4
 
5
5
  export default getTrad;
@@ -1,4 +1,4 @@
1
- const getType = mime => {
1
+ const getType = (mime) => {
2
2
  if (!mime) {
3
3
  return 'file';
4
4
  }
@@ -1,14 +1,11 @@
1
1
  import { get } from 'lodash';
2
2
 
3
- const getYupError = error => {
3
+ const getYupError = (error) => {
4
4
  return get(error, 'inner', []).reduce((acc, curr) => {
5
- acc[
6
- curr.path
7
- .split('[')
8
- .join('.')
9
- .split(']')
10
- .join('')
11
- ] = { id: curr.message, number: curr.params.wrongURLsNumber };
5
+ acc[curr.path.split('[').join('.').split(']').join('')] = {
6
+ id: curr.message,
7
+ number: curr.params.wrongURLsNumber,
8
+ };
12
9
 
13
10
  return acc;
14
11
  }, {});
@@ -5,7 +5,7 @@ function unformatBytes(value) {
5
5
  const number = value.split(/KB|MB|GB/)[0];
6
6
  const unit = value.split(number)[1];
7
7
 
8
- const i = sizes.findIndex(size => size === unit);
8
+ const i = sizes.findIndex((size) => size === unit);
9
9
 
10
10
  const multiplicator = k ** i;
11
11
  const newValue = number * multiplicator;
@@ -12,7 +12,7 @@ const urlSchema = yup.object().shape({
12
12
  name: 'isUrlValid',
13
13
  message: '${path}',
14
14
  test(values) {
15
- const filtered = values.filter(val => {
15
+ const filtered = values.filter((val) => {
16
16
  try {
17
17
  // eslint-disable-next-line no-new
18
18
  new URL(val);
@@ -28,13 +28,15 @@ module.exports = async () => {
28
28
  await registerPermissionActions();
29
29
  };
30
30
 
31
- const wrapFunctionForErrors = fn => async (...args) => {
32
- try {
33
- return await fn(...args);
34
- } catch (err) {
35
- throw convertToStrapiError(err);
36
- }
37
- };
31
+ const wrapFunctionForErrors =
32
+ (fn) =>
33
+ async (...args) => {
34
+ try {
35
+ return await fn(...args);
36
+ } catch (err) {
37
+ throw convertToStrapiError(err);
38
+ }
39
+ };
38
40
 
39
41
  const createProvider = ({ provider, providerOptions, actionOptions = {} }) => {
40
42
  try {
@@ -86,7 +88,7 @@ const pruneObsoleteRelationsQuery = ({ model }) => {
86
88
  }
87
89
 
88
90
  const models = Array.from(strapi.db.models.values());
89
- const modelsId = models.map(model => model.globalId);
91
+ const modelsId = models.map((model) => model.globalId);
90
92
 
91
93
  return model.updateMany(
92
94
  { related: { $elemMatch: { kind: { $nin: modelsId } } } },
@@ -44,11 +44,11 @@ module.exports = {
44
44
  description: 'Upload one file',
45
45
  resolverOf: 'plugins::upload.upload.upload',
46
46
  resolver: async (obj, { files: uploads, ...fields }) => {
47
- const files = await Promise.all(uploads.map(upload => formatFile(upload, {}, fields)));
47
+ const files = await Promise.all(uploads.map((upload) => formatFile(upload, {}, fields)));
48
48
 
49
49
  const uploadService = strapi.plugins.upload.services.upload;
50
50
 
51
- return Promise.all(files.map(file => uploadService.uploadFileAndPersist(file)));
51
+ return Promise.all(files.map((file) => uploadService.uploadFileAndPersist(file)));
52
52
  },
53
53
  },
54
54
  updateFileInfo: {
package/errors.js CHANGED
@@ -5,14 +5,14 @@ const errorTypes = {
5
5
  UNKNOWN_ERROR: 'unknownError',
6
6
  };
7
7
 
8
- const entityTooLarge = message => {
8
+ const entityTooLarge = (message) => {
9
9
  const error = new Error(message || 'Entity too large');
10
10
  error.type = errorTypes.ENTITY_TOO_LARGE;
11
11
  return error;
12
12
  };
13
13
  entityTooLarge.type = errorTypes.ENTITY_TOO_LARGE;
14
14
 
15
- const unknownError = message => {
15
+ const unknownError = (message) => {
16
16
  const error = new Error(message || 'Unknown error');
17
17
  error.type = errorTypes.UNKNOWN_ERROR;
18
18
  return error;
@@ -23,7 +23,7 @@ const is = (err, errorFactory) => {
23
23
  return err.type && err.type === errorFactory.type;
24
24
  };
25
25
 
26
- const convertToStrapiError = err => {
26
+ const convertToStrapiError = (err) => {
27
27
  if (is(err, entityTooLarge)) {
28
28
  return strapi.errors.entityTooLarge('FileTooBig', {
29
29
  errors: [
@@ -5,7 +5,7 @@ const range = require('koa-range');
5
5
  const koaStatic = require('koa-static');
6
6
  const _ = require('lodash');
7
7
 
8
- module.exports = strapi => ({
8
+ module.exports = (strapi) => ({
9
9
  initialize() {
10
10
  const configPublicPath = strapi.config.get(
11
11
  'middleware.settings.public.path',
@@ -13,7 +13,7 @@ module.exports = strapi => ({
13
13
  );
14
14
  const staticDir = resolve(strapi.dir, configPublicPath);
15
15
 
16
- strapi.app.on('error', err => {
16
+ strapi.app.on('error', (err) => {
17
17
  if (err.code === 'EPIPE') {
18
18
  // when serving audio or video the browsers sometimes close the connection to go to range requests instead.
19
19
  // This causes koa to emit a write EPIPE error. We can ignore it.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.7.0",
6
+ "version": "3.7.2",
7
7
  "description": "Makes it easy to upload images and files to your Strapi Application.",
8
8
  "strapi": {
9
9
  "name": "Media Library",
@@ -15,9 +15,9 @@
15
15
  "test": "echo \"no tests yet\""
16
16
  },
17
17
  "dependencies": {
18
- "@akemona-org/strapi-helper-plugin": "3.7.0",
19
- "@akemona-org/strapi-provider-upload-local": "3.7.0",
20
- "@akemona-org/strapi-utils": "3.7.0",
18
+ "@akemona-org/strapi-helper-plugin": "3.7.2",
19
+ "@akemona-org/strapi-provider-upload-local": "3.7.2",
20
+ "@akemona-org/strapi-utils": "3.7.2",
21
21
  "@buffetjs/core": "3.3.8",
22
22
  "@buffetjs/custom": "3.3.8",
23
23
  "@buffetjs/hooks": "3.3.8",
@@ -67,5 +67,5 @@
67
67
  "npm": ">=6.0.0"
68
68
  },
69
69
  "license": "SEE LICENSE IN LICENSE",
70
- "gitHead": "129a8d6191b55810fd66448dcc47fee829df986c"
70
+ "gitHead": "4ab59dbae5135819558c6ae27b45a556ff27cf55"
71
71
  }
@@ -6,12 +6,12 @@ const sharp = require('sharp');
6
6
 
7
7
  const { bytesToKbytes } = require('../utils/file');
8
8
 
9
- const getMetadatas = buffer =>
9
+ const getMetadatas = (buffer) =>
10
10
  sharp(buffer)
11
11
  .metadata()
12
12
  .catch(() => ({})); // ignore errors
13
13
 
14
- const getDimensions = buffer =>
14
+ const getDimensions = (buffer) =>
15
15
  getMetadatas(buffer)
16
16
  .then(({ width = null, height = null }) => ({ width, height }))
17
17
  .catch(() => ({})); // ignore errors
@@ -29,7 +29,7 @@ const resizeTo = (buffer, options) =>
29
29
  .toBuffer()
30
30
  .catch(() => null);
31
31
 
32
- const generateThumbnail = async file => {
32
+ const generateThumbnail = async (file) => {
33
33
  if (!(await canBeProccessed(file.buffer))) {
34
34
  return null;
35
35
  }
@@ -59,11 +59,9 @@ const generateThumbnail = async file => {
59
59
  return null;
60
60
  };
61
61
 
62
- const optimize = async buffer => {
63
- const {
64
- sizeOptimization = false,
65
- autoOrientation = false,
66
- } = await strapi.plugins.upload.services.upload.getSettings();
62
+ const optimize = async (buffer) => {
63
+ const { sizeOptimization = false, autoOrientation = false } =
64
+ await strapi.plugins.upload.services.upload.getSettings();
67
65
 
68
66
  if (!sizeOptimization || !(await canBeProccessed(buffer))) {
69
67
  return { buffer };
@@ -96,10 +94,9 @@ const DEFAULT_BREAKPOINTS = {
96
94
 
97
95
  const getBreakpoints = () => strapi.config.get('plugins.upload.breakpoints', DEFAULT_BREAKPOINTS);
98
96
 
99
- const generateResponsiveFormats = async file => {
100
- const {
101
- responsiveDimensions = false,
102
- } = await strapi.plugins.upload.services.upload.getSettings();
97
+ const generateResponsiveFormats = async (file) => {
98
+ const { responsiveDimensions = false } =
99
+ await strapi.plugins.upload.services.upload.getSettings();
103
100
 
104
101
  if (!responsiveDimensions) return [];
105
102
 
@@ -111,7 +108,7 @@ const generateResponsiveFormats = async file => {
111
108
 
112
109
  const breakpoints = getBreakpoints();
113
110
  return Promise.all(
114
- Object.keys(breakpoints).map(key => {
111
+ Object.keys(breakpoints).map((key) => {
115
112
  const breakpoint = breakpoints[key];
116
113
 
117
114
  if (breakpointSmallerThan(breakpoint, originalDimensions)) {
@@ -153,7 +150,7 @@ const breakpointSmallerThan = (breakpoint, { width, height }) => {
153
150
  };
154
151
 
155
152
  const formatsToProccess = ['jpeg', 'png', 'webp', 'tiff'];
156
- const canBeProccessed = async buffer => {
153
+ const canBeProccessed = async (buffer) => {
157
154
  const { format } = await getMetadatas(buffer);
158
155
  return format && formatsToProccess.includes(format);
159
156
  };
package/utils/file.js CHANGED
@@ -3,12 +3,12 @@
3
3
  * Utils file containing file treatment utils
4
4
  */
5
5
 
6
- const bytesToKbytes = bytes => Math.round((bytes / 1000) * 100) / 100;
6
+ const bytesToKbytes = (bytes) => Math.round((bytes / 1000) * 100) / 100;
7
7
 
8
- const streamToBuffer = stream =>
8
+ const streamToBuffer = (stream) =>
9
9
  new Promise((resolve, reject) => {
10
10
  const chunks = [];
11
- stream.on('data', chunk => {
11
+ stream.on('data', (chunk) => {
12
12
  chunks.push(chunk);
13
13
  });
14
14
  stream.on('end', () => {