picgo-plugin-s3 1.3.7 → 1.3.9

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
@@ -19,36 +19,41 @@ GUI 直接搜索 _S3_ 下载即可,Core 版执行 `picgo add s3` 安装。
19
19
  picgo set uploader aws-s3
20
20
  ```
21
21
 
22
- | Key | 说明 | 例子 |
23
- | -------------------- | ----------------------------------------------------------------------- | -------------------------------------------------------- |
24
- | `accessKeyID` | AWS 凭证 ID | |
25
- | `secretAccessKey` | AWS 凭证密钥 | |
26
- | `bucketName` | S3 桶名称 | `gallery` |
27
- | `uploadPath` | 上传路径 | `{year}/{month}/{fullName}` |
28
- | `urlPrefix` | 最终生成图片 URL 的自定义前缀 | `https://img.example.com/my-blog/` |
29
- | `endpoint` | 指定自定义终端节点 | `s3.us-west-2.amazonaws.com` |
30
- | `proxy` | 代理地址 | 支持http代理,例如 `http://127.0.0.1:1080` |
31
- | `region` | 指定执行服务请求的区域 | `us-west-1` |
32
- | `pathStyleAccess` | 是否启用 S3 Path style | 默认为 `false`,使用 minio 请设置为 `true` (e.g., https://s3.amazonaws.com/<bucketName>/<key> instead of https://<bucketName>.s3.amazonaws.com/<key>) |
33
- | `rejectUnauthorized` | 是否拒绝无效 TLS 证书连接 | 默认为 `true`,如上传失败日志显示证书问题可设置为`false` |
34
- | `acl` | 访问控制列表,上传资源的访问策略 | 默认为 `public-read`, AWS 可选 `private"|"public-read"|"public-read-write"|"authenticated-read"|"aws-exec-read"|"bucket-owner-read"|"bucket-owner-full-control` |
35
- | `disableBucketPrefixToURL` | 开启 `pathStyleAccess` 时,是否要禁用最终生成URL中添加 bucket 前缀 | 默认为 `false` |
22
+ | Key | 说明 | 例子 |
23
+ |----------------------------|--------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------|
24
+ | `accessKeyID` | AWS 凭证 ID | |
25
+ | `secretAccessKey` | AWS 凭证密钥 | |
26
+ | `bucketName` | S3 桶名称 | `gallery` |
27
+ | `uploadPath` | 上传路径 | `{year}/{month}/{fullName}` |
28
+ | `urlPrefix` | 最终生成图片 URL 的自定义前缀 | `https://img.example.com/my-blog/` |
29
+ | `urlSuffix` | 最终生成图片 URL 的自定义后缀 | `?oxx=xxx` |
30
+ | `endpoint` | 指定自定义终端节点 | `s3.us-west-2.amazonaws.com` |
31
+ | `proxy` | 代理地址 | 支持 http 代理,例如 `http://127.0.0.1:1080` |
32
+ | `region` | 指定执行服务请求的区域 | `us-west-1` |
33
+ | `pathStyleAccess` | 是否启用 S3 Path style | 默认为 `false`,使用 minio 请设置为 `true` (e.g., https://s3.amazonaws.com/<bucketName>/<key> instead of https://<bucketName>.s3.amazonaws.com/<key>) |
34
+ | `rejectUnauthorized` | 是否拒绝无效 TLS 证书连接 | 默认为 `true`,如上传失败日志显示证书问题可设置为`false` |
35
+ | `acl` | 访问控制列表,上传资源的访问策略 | 默认为 `public-read`, AWS 可选 `private" |"public-read"|"public-read-write"|"authenticated-read"|"aws-exec-read"|"bucket-owner-read"|"bucket-owner-full-control` |
36
+ | `disableBucketPrefixToURL` | 开启 `pathStyleAccess` 时,是否要禁用最终生成 URL 中添加 bucket 前缀 | 默认为 `false` |
36
37
 
37
38
  **上传路径支持 payload:**
38
39
 
39
- | payload | 描述 |
40
- | ------------ | ---------------------- |
41
- | `{year}` | 当前日期 - 年 |
42
- | `{month}` | 当前日期 - 月 |
43
- | `{day}` | 当前日期 - 日 |
44
- | `{fullName}` | 完整文件名(含扩展名) |
45
- | `{fileName}` | 文件名(不含扩展名) |
46
- | `{extName}` | 扩展名(不含`.`) |
47
- | `{md5}` | 图片 MD5 计算值 |
48
- | `{sha1}` | 图片 SHA1 计算值 |
49
- | `{sha256}` | 图片 SHA256 计算值 |
50
- | `{timestamp}` | Unix 时间戳 |
51
- | `{timestampMS}` | Unix 时间戳(毫秒) |
40
+ | payload | 描述 |
41
+ | --------------- | ---------------------- |
42
+ | `{year}` | 当前日期 - 年 |
43
+ | `{month}` | 当前日期 - 月 |
44
+ | `{day}` | 当前日期 - 日 |
45
+ | `{hour}` | 当前日期 - 时 |
46
+ | `{minute}` | 当前日期 - 分 |
47
+ | `{second}` | 当前日期 - 秒 |
48
+ | `{millisecond}` | 当前日期 - 毫秒 |
49
+ | `{fullName}` | 完整文件名(含扩展名) |
50
+ | `{fileName}` | 文件名(不含扩展名) |
51
+ | `{extName}` | 扩展名(不含`.`) |
52
+ | `{md5}` | 图片 MD5 计算值 |
53
+ | `{sha1}` | 图片 SHA1 计算值 |
54
+ | `{sha256}` | 图片 SHA256 计算值 |
55
+ | `{timestamp}` | Unix 时间戳 |
56
+ | `{timestampMS}` | Unix 时间戳(毫秒) |
52
57
 
53
58
  ### 示例 Example
54
59
 
package/dist/config.d.ts CHANGED
@@ -11,4 +11,5 @@ export interface IS3UserConfig {
11
11
  rejectUnauthorized?: boolean;
12
12
  acl?: string;
13
13
  disableBucketPrefixToURL?: boolean;
14
+ urlSuffix?: string;
14
15
  }
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ module.exports = (ctx) => {
14
14
  pathStyleAccess: false,
15
15
  rejectUnauthorized: true,
16
16
  acl: "public-read",
17
+ urlSuffix: "",
17
18
  };
18
19
  let userConfig = ctx.getConfig("picBed.aws-s3");
19
20
  userConfig = Object.assign(Object.assign({}, defaultConfig), (userConfig || {}));
@@ -78,6 +79,14 @@ module.exports = (ctx) => {
78
79
  required: false,
79
80
  alias: "自定义域名",
80
81
  },
82
+ {
83
+ name: "urlSuffix",
84
+ type: "input",
85
+ default: userConfig.urlSuffix || "",
86
+ message: "例如?x-oss-process=xxx",
87
+ required: false,
88
+ alias: "设定网址后缀",
89
+ },
81
90
  {
82
91
  name: "pathStyleAccess",
83
92
  type: "confirm",
@@ -153,8 +162,8 @@ module.exports = (ctx) => {
153
162
  const { index, url, imgURL } = result;
154
163
  delete output[index].buffer;
155
164
  delete output[index].base64Image;
156
- output[index].imgUrl = imgURL;
157
- output[index].url = url;
165
+ output[index].imgUrl = `${imgURL}${(userConfig === null || userConfig === void 0 ? void 0 : userConfig.urlSuffix) || ''}`;
166
+ output[index].url = `${url}${(userConfig === null || userConfig === void 0 ? void 0 : userConfig.urlSuffix) || ''}`;
158
167
  }
159
168
  return ctx;
160
169
  };
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { IImgInfo } from "picgo";
3
2
  import { HttpsProxyAgent, HttpProxyAgent } from "hpagent";
4
3
  export declare function formatPath(info: IImgInfo, format?: string): string;
package/dist/utils.js CHANGED
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getProxyAgent = exports.extractInfo = exports.formatPath = void 0;
6
+ exports.formatPath = formatPath;
7
+ exports.extractInfo = extractInfo;
8
+ exports.getProxyAgent = getProxyAgent;
7
9
  const crypto_1 = __importDefault(require("crypto"));
8
10
  const file_type_1 = require("file-type");
9
11
  const mime_1 = __importDefault(require("mime"));
@@ -26,6 +28,18 @@ class FileNameGenerator {
26
28
  ? `0${this.date.getDate()}`
27
29
  : `${this.date.getDate()}`;
28
30
  }
31
+ hour() {
32
+ return this.date.getHours().toString().padStart(2, "0");
33
+ }
34
+ minute() {
35
+ return this.date.getMinutes().toString().padStart(2, "0");
36
+ }
37
+ second() {
38
+ return this.date.getSeconds().toString().padStart(2, "0");
39
+ }
40
+ millisecond() {
41
+ return this.date.getMilliseconds().toString().padStart(3, "0");
42
+ }
29
43
  fullName() {
30
44
  return this.info.fileName;
31
45
  }
@@ -76,6 +90,10 @@ FileNameGenerator.fields = [
76
90
  "year",
77
91
  "month",
78
92
  "day",
93
+ "hour",
94
+ "minute",
95
+ "second",
96
+ "millisecond",
79
97
  "fullName",
80
98
  "fileName",
81
99
  "extName",
@@ -99,7 +117,6 @@ function formatPath(info, format) {
99
117
  }
100
118
  return formatPath;
101
119
  }
102
- exports.formatPath = formatPath;
103
120
  async function extractInfo(info) {
104
121
  var _a;
105
122
  const result = {};
@@ -122,7 +139,6 @@ async function extractInfo(info) {
122
139
  }
123
140
  return result;
124
141
  }
125
- exports.extractInfo = extractInfo;
126
142
  function formatHttpProxyURL(url = "") {
127
143
  if (!url)
128
144
  return "";
@@ -153,4 +169,3 @@ function getProxyAgent(proxy, sslEnabled, rejectUnauthorized) {
153
169
  };
154
170
  return new Agent(options);
155
171
  }
156
- exports.getProxyAgent = getProxyAgent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "picgo-plugin-s3",
3
- "version": "1.3.7",
3
+ "version": "1.3.9",
4
4
  "description": "picgo amazon s3 uploader",
5
5
  "main": "dist/index.js",
6
6
  "publishConfig": {