(objectName: string, value: string)
| 103 | const tempDir = mkdtempSync(join(tmpdir(), "spec-blobs-")); |
| 104 | |
| 105 | const putBlobR2 = (objectName: string, value: string): void => { |
| 106 | const file = join(tempDir, "blob-upload"); |
| 107 | writeFileSync(file, value, "utf8"); |
| 108 | execFileSync( |
| 109 | "wrangler", |
| 110 | ["r2", "object", "put", `${bucket}/${objectName}`, "--file", file, "--remote"], |
| 111 | { stdio: ["ignore", "ignore", "inherit"] }, |
| 112 | ); |
| 113 | const verifyFile = join(tempDir, "blob-verify"); |
| 114 | execFileSync( |
| 115 | "wrangler", |
| 116 | ["r2", "object", "get", `${bucket}/${objectName}`, "--file", verifyFile, "--remote"], |
| 117 | { stdio: ["ignore", "ignore", "inherit"] }, |
| 118 | ); |
| 119 | const roundTripped = readFileSync(verifyFile, "utf8"); |
| 120 | if (sha256Hex(roundTripped) !== sha256Hex(value)) { |
| 121 | throw new Error(`R2 round-trip mismatch for ${objectName}`); |
| 122 | } |
| 123 | }; |
| 124 | |
| 125 | const putBlobDb = async (namespace: string, key: string, value: string): Promise<void> => { |
| 126 | const id = fumaBlobId(namespace, key); |
no test coverage detected