speedly 1.2.23 → 1.2.27

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.
@@ -30,7 +30,7 @@ exports.default = (destination = "/image", config = configs) => {
30
30
  ? destination(req, file)
31
31
  : destination;
32
32
  const splitPath = dest.split("/");
33
- let currentPath = path_1.default.join(require.main.filename || '', configs.path);
33
+ let currentPath = path_1.default.join(configs.path);
34
34
  splitPath.forEach(folder => {
35
35
  currentPath = path_1.default.join(currentPath, folder);
36
36
  console.log('uploader', 39, currentPath, !fs_1.default.existsSync(currentPath));
@@ -38,7 +38,7 @@ exports.default = (destination = "/image", config = configs) => {
38
38
  fs_1.default.mkdirSync(currentPath);
39
39
  }
40
40
  });
41
- cb(null, path_1.default.join(require.main.filename || '', configs.path, dest));
41
+ cb(null, path_1.default.join(configs.path, dest));
42
42
  }
43
43
  catch (err) {
44
44
  cb(err, "");
@@ -53,7 +53,7 @@ exports.default = (destination = "/image", config = configs) => {
53
53
  const originalName = Buffer.from(file.originalname, "latin1").toString("utf8");
54
54
  const fileName = (configs.prefix ? configs.prefix + "-" : "") +
55
55
  originalName.replace(/\.\w+$/, "") + ext;
56
- const filePath = path_1.default.join(require.main.filename || '', configs.path, dest, fileName);
56
+ const filePath = path_1.default.join(configs.path, dest, fileName);
57
57
  console.log('uploader', 65, filePath);
58
58
  try {
59
59
  fs_1.default.existsSync(filePath);
@@ -103,7 +103,7 @@ exports.default = (destination = "/image", config = configs) => {
103
103
  req.mediaId = mediaDoc.insertedId;
104
104
  }
105
105
  req.body[fieldName] = path_1.default
106
- .join("/static", path_1.default.relative(path_1.default.join(require.main.filename || '', configs.path), req.file.path))
106
+ .join("/static", path_1.default.relative(path_1.default.join(configs.path), req.file.path))
107
107
  .replaceAll(/\\/g, "/");
108
108
  }
109
109
  next();
@@ -115,7 +115,7 @@ exports.default = (destination = "/image", config = configs) => {
115
115
  return res.status(405).json({ message: err.message });
116
116
  if (req.files && Array.isArray(req.files) && req.files.length) {
117
117
  req.body[fieldName] = req.files.map(file => path_1.default
118
- .join("/static", path_1.default.relative(path_1.default.join(require.main.filename || '', configs.path), file.path))
118
+ .join("/static", path_1.default.relative(path_1.default.join(configs.path), file.path))
119
119
  .replaceAll(/\\/g, "/"));
120
120
  }
121
121
  next();
@@ -30,7 +30,7 @@ exports.default = (destination = "/image", config = configs) => {
30
30
  ? destination(req, file)
31
31
  : destination;
32
32
  const splitPath = dest.split("/");
33
- let currentPath = path_1.default.join(require.main.filename || '', configs.path);
33
+ let currentPath = path_1.default.join(configs.path);
34
34
  splitPath.forEach(folder => {
35
35
  currentPath = path_1.default.join(currentPath, folder);
36
36
  console.log('uploader', 39, currentPath, !fs_1.default.existsSync(currentPath));
@@ -38,7 +38,7 @@ exports.default = (destination = "/image", config = configs) => {
38
38
  fs_1.default.mkdirSync(currentPath);
39
39
  }
40
40
  });
41
- cb(null, path_1.default.join(require.main.filename || '', configs.path, dest));
41
+ cb(null, path_1.default.join(configs.path, dest));
42
42
  }
43
43
  catch (err) {
44
44
  cb(err, "");
@@ -53,7 +53,7 @@ exports.default = (destination = "/image", config = configs) => {
53
53
  const originalName = Buffer.from(file.originalname, "latin1").toString("utf8");
54
54
  const fileName = (configs.prefix ? configs.prefix + "-" : "") +
55
55
  originalName.replace(/\.\w+$/, "") + ext;
56
- const filePath = path_1.default.join(require.main.filename || '', configs.path, dest, fileName);
56
+ const filePath = path_1.default.join(configs.path, dest, fileName);
57
57
  console.log('uploader', 65, filePath);
58
58
  try {
59
59
  fs_1.default.existsSync(filePath);
@@ -103,7 +103,7 @@ exports.default = (destination = "/image", config = configs) => {
103
103
  req.mediaId = mediaDoc.insertedId;
104
104
  }
105
105
  req.body[fieldName] = path_1.default
106
- .join("/static", path_1.default.relative(path_1.default.join(require.main.filename || '', configs.path), req.file.path))
106
+ .join("/static", path_1.default.relative(path_1.default.join(configs.path), req.file.path))
107
107
  .replaceAll(/\\/g, "/");
108
108
  }
109
109
  next();
@@ -115,7 +115,7 @@ exports.default = (destination = "/image", config = configs) => {
115
115
  return res.status(405).json({ message: err.message });
116
116
  if (req.files && Array.isArray(req.files) && req.files.length) {
117
117
  req.body[fieldName] = req.files.map(file => path_1.default
118
- .join("/static", path_1.default.relative(path_1.default.join(require.main.filename || '', configs.path), file.path))
118
+ .join("/static", path_1.default.relative(path_1.default.join(configs.path), file.path))
119
119
  .replaceAll(/\\/g, "/"));
120
120
  }
121
121
  next();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "speedly",
3
- "version": "1.2.23",
3
+ "version": "1.2.27",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/esm/index.d.ts",