picgo-plugin-s3 1.3.3 → 1.3.6

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.
package/README.md CHANGED
@@ -47,6 +47,8 @@ picgo set uploader aws-s3
47
47
  | `{md5}` | 图片 MD5 计算值 |
48
48
  | `{sha1}` | 图片 SHA1 计算值 |
49
49
  | `{sha256}` | 图片 SHA256 计算值 |
50
+ | `{timestamp}` | Unix 时间戳 |
51
+ | `{timestampMS}` | Unix 时间戳(毫秒) |
50
52
 
51
53
  ### 示例 Example
52
54
 
package/dist/index.js CHANGED
@@ -117,10 +117,11 @@ module.exports = (ctx) => {
117
117
  if (!userConfig) {
118
118
  throw new Error("Can't find amazon s3 uploader config");
119
119
  }
120
- if (userConfig.urlPrefix) {
121
- userConfig.urlPrefix = userConfig.urlPrefix.replace(/\/?$/, "");
120
+ let urlPrefix = userConfig.urlPrefix;
121
+ if (urlPrefix) {
122
+ urlPrefix = urlPrefix.replace(/\/?$/, "");
122
123
  if (userConfig.pathStyleAccess && !userConfig.disableBucketPrefixToURL) {
123
- userConfig.urlPrefix += "/" + userConfig.bucketName;
124
+ urlPrefix += "/" + userConfig.bucketName;
124
125
  }
125
126
  }
126
127
  const client = uploader_1.default.createS3Client(userConfig);
@@ -132,7 +133,7 @@ module.exports = (ctx) => {
132
133
  path: (0, utils_1.formatPath)(item, userConfig.uploadPath),
133
134
  item: item,
134
135
  acl: userConfig.acl,
135
- urlPrefix: userConfig.urlPrefix,
136
+ urlPrefix,
136
137
  }));
137
138
  let results;
138
139
  try {
package/dist/uploader.js CHANGED
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const client_s3_1 = require("@aws-sdk/client-s3");
7
7
  const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
8
- const node_http_handler_1 = require("@aws-sdk/node-http-handler");
8
+ const node_http_handler_1 = require("@smithy/node-http-handler");
9
9
  const url_1 = __importDefault(require("url"));
10
10
  const utils_1 = require("./utils");
11
11
  function createS3Client(opts) {
@@ -52,10 +52,11 @@ async function createUploadTask(opts) {
52
52
  catch (err) {
53
53
  return Promise.reject(err);
54
54
  }
55
+ const acl = opts.acl;
55
56
  const command = new client_s3_1.PutObjectCommand({
56
57
  Bucket: opts.bucketName,
57
58
  Key: opts.path,
58
- ACL: opts.acl,
59
+ ACL: acl,
59
60
  Body: body,
60
61
  ContentType: contentType,
61
62
  ContentEncoding: contentEncoding,
package/dist/utils.js CHANGED
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getProxyAgent = exports.extractInfo = exports.formatPath = void 0;
7
7
  const crypto_1 = __importDefault(require("crypto"));
8
- const file_type_1 = __importDefault(require("file-type"));
8
+ const file_type_1 = require("file-type");
9
9
  const mime_1 = __importDefault(require("mime"));
10
10
  const hpagent_1 = require("hpagent");
11
11
  class FileNameGenerator {
@@ -62,6 +62,12 @@ class FileNameGenerator {
62
62
  sha256() {
63
63
  return crypto_1.default.createHash("sha256").update(this.imgBuffer()).digest("hex");
64
64
  }
65
+ timestamp() {
66
+ return Math.floor(Date.now() / 1000).toString();
67
+ }
68
+ timestampMS() {
69
+ return Date.now().toString();
70
+ }
65
71
  imgBuffer() {
66
72
  return this.info.base64Image ? this.info.base64Image : this.info.buffer;
67
73
  }
@@ -78,6 +84,8 @@ FileNameGenerator.fields = [
78
84
  "md5B64Short",
79
85
  "sha1",
80
86
  "sha256",
87
+ "timestamp",
88
+ "timestampMS",
81
89
  ];
82
90
  function formatPath(info, format) {
83
91
  if (!format) {
@@ -109,7 +117,7 @@ async function extractInfo(info) {
109
117
  }
110
118
  // fallback to detect from buffer
111
119
  if (!result.contentType) {
112
- const fileType = await file_type_1.default.fromBuffer(result.body);
120
+ const fileType = await (0, file_type_1.fromBuffer)(result.body);
113
121
  result.contentType = fileType === null || fileType === void 0 ? void 0 : fileType.mime;
114
122
  }
115
123
  return result;
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "picgo-plugin-s3",
3
- "version": "1.3.3",
3
+ "version": "1.3.6",
4
4
  "description": "picgo amazon s3 uploader",
5
5
  "main": "dist/index.js",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
+ "type": "commonjs",
9
10
  "homepage": "https://github.com/wayjam/picgo-plugin-s3",
10
11
  "scripts": {
11
12
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -28,24 +29,24 @@
28
29
  "author": "WayJam So",
29
30
  "license": "MIT",
30
31
  "devDependencies": {
31
- "@types/mime": "^3.0.1",
32
- "@types/node": "^18.7.23",
33
- "@typescript-eslint/eslint-plugin": "^5.38.1",
34
- "@typescript-eslint/parser": "^5.38.1",
35
- "eslint": "^8.25.0",
36
- "eslint-config-prettier": "^8.5.0",
37
- "eslint-plugin-prettier": "^4.2.1",
38
- "prettier": "^2.7.1",
39
- "typescript": "^4.8.4"
32
+ "@types/mime": "^3.0.4",
33
+ "@types/node": "^20.12.7",
34
+ "@typescript-eslint/eslint-plugin": "^6.21.0",
35
+ "@typescript-eslint/parser": "^6.21.0",
36
+ "eslint": "^8.57.0",
37
+ "eslint-config-prettier": "^9.1.0",
38
+ "eslint-plugin-prettier": "^5.1.3",
39
+ "prettier": "^3.2.5",
40
+ "typescript": "^5.4.5"
40
41
  },
41
42
  "dependencies": {
42
- "@aws-sdk/client-s3": "^3.304.0",
43
- "@aws-sdk/lib-storage": "^3.304.0",
44
- "@aws-sdk/node-http-handler": "^3.360.0",
45
- "@aws-sdk/s3-request-presigner": "^3.305.0",
46
- "file-type": "^16.2.0",
43
+ "@aws-sdk/client-s3": "^3.556.0",
44
+ "@aws-sdk/lib-storage": "^3.556.0",
45
+ "@aws-sdk/node-http-handler": "^3.374.0",
46
+ "@aws-sdk/s3-request-presigner": "^3.556.0",
47
+ "file-type": ">16.5.0 <17.0.0",
47
48
  "hpagent": "^1.2.0",
48
- "mime": "^2.5.2",
49
- "picgo": "^1.5.3"
49
+ "mime": "^3.0.0",
50
+ "picgo": "^1.5.6"
50
51
  }
51
52
  }