picgo-plugin-s3 1.3.0 → 1.3.1
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/dist/index.js +3 -0
- package/dist/uploader.js +6 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -111,6 +111,9 @@ module.exports = (ctx) => {
|
|
|
111
111
|
}
|
|
112
112
|
if (userConfig.urlPrefix) {
|
|
113
113
|
userConfig.urlPrefix = userConfig.urlPrefix.replace(/\/?$/, "");
|
|
114
|
+
if (userConfig.pathStyleAccess) {
|
|
115
|
+
userConfig.urlPrefix += "/" + userConfig.bucketName;
|
|
116
|
+
}
|
|
114
117
|
}
|
|
115
118
|
const client = uploader_1.default.createS3Client(userConfig);
|
|
116
119
|
const output = ctx.output;
|
package/dist/uploader.js
CHANGED
|
@@ -6,8 +6,8 @@ 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
8
|
const node_http_handler_1 = require("@aws-sdk/node-http-handler");
|
|
9
|
-
const utils_1 = require("./utils");
|
|
10
9
|
const url_1 = __importDefault(require("url"));
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
11
|
function createS3Client(opts) {
|
|
12
12
|
let sslEnabled = true;
|
|
13
13
|
try {
|
|
@@ -26,7 +26,7 @@ function createS3Client(opts) {
|
|
|
26
26
|
}
|
|
27
27
|
const clientOptions = {
|
|
28
28
|
region: opts.region || "auto",
|
|
29
|
-
endpoint: opts.endpoint,
|
|
29
|
+
endpoint: opts.endpoint || undefined,
|
|
30
30
|
credentials: {
|
|
31
31
|
accessKeyId: opts.accessKeyID,
|
|
32
32
|
secretAccessKey: opts.secretAccessKey,
|
|
@@ -90,12 +90,15 @@ async function createUploadTask(opts) {
|
|
|
90
90
|
}
|
|
91
91
|
async function getFileURL(opts, eTag, versionId) {
|
|
92
92
|
try {
|
|
93
|
-
|
|
93
|
+
const signedUrl = await (0, s3_request_presigner_1.getSignedUrl)(opts.client, new client_s3_1.GetObjectCommand({
|
|
94
94
|
Bucket: opts.bucketName,
|
|
95
95
|
Key: opts.path,
|
|
96
96
|
IfMatch: eTag,
|
|
97
97
|
VersionId: versionId,
|
|
98
98
|
}), { expiresIn: 3600 });
|
|
99
|
+
const urlObject = new URL(signedUrl);
|
|
100
|
+
urlObject.search = "";
|
|
101
|
+
return urlObject.href;
|
|
99
102
|
}
|
|
100
103
|
catch (err) {
|
|
101
104
|
return Promise.reject(err);
|