MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / write

Method write

packages/filesystem/s3/rw.ts:61–76  ·  view source on GitHub ↗

* 写入文件内容 * @param content 文件内容(字符串或 Blob) * @throws {S3Error} 上传失败

(content: string | Blob)

Source from the content-addressed store, hash-verified

59 * @throws {S3Error} 上传失败
60 */
61 async write(content: string | Blob): Promise<void> {
62 const body = content instanceof Blob ? new Uint8Array(await content.arrayBuffer()) : content;
63
64 const headers: Record<string, string> = {
65 "content-type": "application/octet-stream",
66 };
67 if (this.modifiedDate) {
68 // 历史兼容:S3 侧使用 createtime 元数据保存文件时间,实际来源是 FileCreateOptions.modifiedDate。
69 headers["x-amz-meta-createtime"] = new Date(this.modifiedDate).toISOString();
70 }
71
72 await this.client.request("PUT", this.bucket, this.key, {
73 body: typeof body === "string" ? body : body,
74 headers,
75 });
76 }
77}

Callers

nothing calls this directly

Calls 2

arrayBufferMethod · 0.45
requestMethod · 0.45

Tested by

no test coverage detected