Skip to content

Commit 579c975

Browse files
committed
fix: removing utf8 when reading file
1 parent dfe9877 commit 579c975

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

lib/platform/actions/core/storage.actions.js

+22-7
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,41 @@ async function uploadStatics(versionId, basePath, currentPath = '') {
4141
const fileStat = await promisify(fs.stat)(fullFilePath);
4242

4343
if (fileStat.isFile()) {
44-
const fileContent = await promisify(fs.readFile)(fullFilePath, 'utf8');
44+
const fileContent = await promisify(fs.readFile)(fullFilePath);
4545
const mimeType = mime.lookup(fullFilePath);
4646
const staticPath = path.join(currentPath, filePath).replace(/\\/g, '/');
4747

4848
try {
49-
const response = await StorageService.upload(versionId, fileContent, staticPath, mimeType);
49+
const response = await StorageService.upload(
50+
versionId,
51+
fileContent,
52+
staticPath,
53+
mimeType,
54+
);
5055
if (response.statusText === 'OK') {
5156
successUploadCount += 1;
5257
feedback.statics.success(
5358
Messages.platform.storage.success.file_uploaded_success(filePath),
5459
);
5560
}
56-
if (!response.status === 'OK') { throw new Error(response); }
61+
if (!response.status === 'OK') {
62+
throw new Error(response);
63+
}
5764
} catch (error) {
58-
feedback.statics.error(Messages.platform.storage.errors.file_upload_failed(filePath));
65+
feedback.statics.error(
66+
Messages.platform.storage.errors.file_upload_failed(filePath),
67+
);
5968
debug.error(error);
6069
}
6170
} else if (fileStat.isDirectory()) {
6271
const subDirPath = path.join(currentPath, filePath);
63-
const subDirFiles = await promisify(fs.readdir)(path.join(basePath, subDirPath));
72+
const subDirFiles = await promisify(fs.readdir)(
73+
path.join(basePath, subDirPath),
74+
);
6475

65-
await Promise.all(subDirFiles.map((file) => uploadFiles(path.join(subDirPath, file))));
76+
await Promise.all(
77+
subDirFiles.map((file) => uploadFiles(path.join(subDirPath, file))),
78+
);
6679
}
6780
}
6881

@@ -75,7 +88,9 @@ async function uploadStatics(versionId, basePath, currentPath = '') {
7588
}
7689

7790
feedback.statics.success(
78-
Messages.platform.storage.success.statics_uploaded_finish(successUploadCount),
91+
Messages.platform.storage.success.statics_uploaded_finish(
92+
successUploadCount,
93+
),
7994
);
8095
return successUploadCount;
8196
}

0 commit comments

Comments
 (0)