|
5 | 5 | setDefaults,
|
6 | 6 | } from "./options.ts";
|
7 | 7 | import type { ErrorLike, NotFoundError } from "@cosense/types/rest";
|
8 |
| -import { Md5 } from "@std/hash"; |
| 8 | +import { md5 } from "@takker/md5"; |
| 9 | +import { encodeHex } from "@std/encoding/hex"; |
9 | 10 | import {
|
10 | 11 | createOk,
|
11 | 12 | isErr,
|
@@ -46,14 +47,14 @@ export const uploadToGCS = async (
|
46 | 47 | projectId: string,
|
47 | 48 | options?: ExtendedOptions,
|
48 | 49 | ): Promise<Result<GCSFile, UploadGCSError | FetchError>> => {
|
49 |
| - const md5 = `${new Md5().update(await file.arrayBuffer())}`; |
50 |
| - const res = await uploadRequest(file, projectId, md5, options); |
| 50 | + const md5Hash = `${encodeHex(md5(await file.arrayBuffer()))}`; |
| 51 | + const res = await uploadRequest(file, projectId, md5Hash, options); |
51 | 52 | if (isErr(res)) return res;
|
52 | 53 | const fileOrRequest = unwrapOk(res);
|
53 | 54 | if ("embedUrl" in fileOrRequest) return createOk(fileOrRequest);
|
54 | 55 | const result = await upload(fileOrRequest.signedUrl, file, options);
|
55 | 56 | if (isErr(result)) return result;
|
56 |
| - return verify(projectId, fileOrRequest.fileId, md5, options); |
| 57 | + return verify(projectId, fileOrRequest.fileId, md5Hash, options); |
57 | 58 | };
|
58 | 59 |
|
59 | 60 | /** 容量を使い切ったときに発生するerror */
|
|
0 commit comments