Skip to content

Commit

Permalink
fix: byte
Browse files Browse the repository at this point in the history
  • Loading branch information
Miracle575 committed Aug 9, 2024
1 parent 47aca6c commit df83c01
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const UploadModal: React.FC<Props> = ({ open, onClose, path, reload, clus
};

const startMultipartUpload = async (file: File, onProgress: OnProgressCallback) => {
const { tempFileDir, chunkSize, filesInfo } = await api.initMultipartUpload({
const { tempFileDir, chunkSizeByte, filesInfo } = await api.initMultipartUpload({
body: { cluster, path, name: file.name },
});

Expand All @@ -81,7 +81,7 @@ export const UploadModal: React.FC<Props> = ({ open, onClose, path, reload, clus
}
}).map((item) => item.name);

const totalCount = Math.ceil(file.size / chunkSize);
const totalCount = Math.ceil(file.size / chunkSizeByte);
const concurrentChunks = 3;
let uploadedCount = uploadedChunks.length;

Expand All @@ -105,7 +105,7 @@ export const UploadModal: React.FC<Props> = ({ open, onClose, path, reload, clus
return;
}

const chunk = file.slice(start * chunkSize, (start + 1) * chunkSize);
const chunk = file.slice(start * chunkSizeByte, (start + 1) * chunkSizeByte);
const hash = await calculateBlobSHA256(chunk);
const fileName = `${hash}_${start + 1}.scowuploadtemp`;

Expand Down Expand Up @@ -140,7 +140,7 @@ export const UploadModal: React.FC<Props> = ({ open, onClose, path, reload, clus

await Promise.all(uploadPromises);

await api.mergeFileChunks({ body: { cluster, path, name: file.name, size: file.size } })
await api.mergeFileChunks({ body: { cluster, path, name: file.name, sizeByte: file.size } })
.httpError(520, (err) => {
message.error(t(p("mergeFileChunksErrorText"), [file.name]));
throw err;
Expand Down
2 changes: 1 addition & 1 deletion apps/portal-web/src/pages/api/file/initMultipartUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const InitMultipartUploadSchema = typeboxRouteSchema({
responses: {
200: Type.Object({
tempFileDir: Type.String(),
chunkSize: Type.Number(),
chunkSizeByte: Type.Number(),
filesInfo: Type.Array(FileInfo),
}),
403: Type.Object({ code: Type.Literal("PERMISSION_DENIED") }),
Expand Down
8 changes: 4 additions & 4 deletions apps/portal-web/src/pages/api/file/mergeFileChunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const MergeFileChunksSchema = typeboxRouteSchema({
cluster: Type.String(),
path: Type.String(),
name: Type.String(),
size: Type.Number(),
sizeByte: Type.Number(),
}),

responses: {
Expand All @@ -49,7 +49,7 @@ export default route(MergeFileChunksSchema, async (req, res) => {

if (!info) { return; }

const { cluster, path, name, size } = req.body;
const { cluster, path, name, sizeByte } = req.body;

const client = getClient(FileServiceClient);

Expand All @@ -58,12 +58,12 @@ export default route(MergeFileChunksSchema, async (req, res) => {
operatorIp: parseIp(req) ?? "",
operationTypeName: OperationType.mergeFileChunks,
operationTypePayload:{
clusterId: cluster, path, name, size,
clusterId: cluster, path, name, sizeByte,
},
};

return asyncUnaryCall(client, "mergeFileChunks", {
cluster, path, userId: info.identityId, name, size,
cluster, path, userId: info.identityId, name, sizeByte,
}).then(async () => {
await callLog(logInfo, OperationResult.SUCCESS);
return { 204: null };
Expand Down
2 changes: 1 addition & 1 deletion protos/audit/operation_log.proto
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ message MergeFileChunks {
string cluster_id = 1;
string path = 2;
string name = 3;
uint64 size = 4;
uint64 size_byte = 4;
}

message CreateDirectory {
Expand Down

0 comments on commit df83c01

Please sign in to comment.