Skip to content

Commit 63cd791

Browse files
committed
fix: s3 upload to folder
1 parent 68d6ad3 commit 63cd791

File tree

1 file changed

+6
-8
lines changed
  • server/node-service/src/plugins/s3

1 file changed

+6
-8
lines changed

server/node-service/src/plugins/s3/run.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ function getFileUrl(dataSourceConfig: DataSourceDataType, bucket: string, fileKe
3636
return "";
3737
}
3838
if (dataSourceConfig.endpointUrl) {
39-
return `${dataSourceConfig.endpointUrl}/${bucket}/${encodeURIComponent(fileKey)}`;
39+
return `${dataSourceConfig.endpointUrl}/${bucket}/${fileKey}`;
4040
}
41-
return `https://s3.${dataSourceConfig.region}.amazonaws.com/${bucket}/${encodeURIComponent(
42-
fileKey
43-
)}`;
41+
return `https://s3.${dataSourceConfig.region}.amazonaws.com/${bucket}/${fileKey}`;
4442
}
4543

4644
async function getFileSignedUrl(bucket: string, fileName: string, client: S3Client) {
@@ -105,7 +103,7 @@ export default async function run(
105103
signedUrl = await getFileSignedUrl(bucket, i.Key, client);
106104
}
107105
files.push({
108-
name: decodeURIComponent(i.Key || ""),
106+
name: i.Key || "",
109107
size: i.Size,
110108
lastModified: i.LastModified,
111109
signedUrl,
@@ -120,7 +118,7 @@ export default async function run(
120118
const res = await client.send(
121119
new GetObjectCommand({
122120
Bucket: bucket,
123-
Key: encodeURIComponent(action.fileName),
121+
Key: action.fileName,
124122
})
125123
);
126124
const data = (await res.Body?.transformToString(action.encoding || "base64")) || "";
@@ -138,7 +136,7 @@ export default async function run(
138136
new PutObjectCommand({
139137
Body: Buffer.from(action.data, (action.encoding || "base64") as BufferEncoding),
140138
Bucket: bucket,
141-
Key: encodeURIComponent(action.fileName),
139+
Key: action.fileName,
142140
ContentType: action.contentType,
143141
})
144142
);
@@ -158,7 +156,7 @@ export default async function run(
158156
await client.send(
159157
new DeleteObjectCommand({
160158
Bucket: bucket,
161-
Key: encodeURIComponent(action.fileName),
159+
Key: action.fileName,
162160
})
163161
);
164162
return {

0 commit comments

Comments
 (0)