(request: RequestLike, response: Response)
| 181 | } |
| 182 | |
| 183 | async put(request: RequestLike, response: Response): Promise<void> { |
| 184 | const url = this.normalizeRequest(request); |
| 185 | const blob = await response.blob(); |
| 186 | const hash = await this.getBlobHash(blob); |
| 187 | const api = this.getApi(); |
| 188 | if (!api) { |
| 189 | throw new Error("Cross-origin storage API unavailable."); |
| 190 | } |
| 191 | const handle = await api.requestFileHandle(hash, { create: true }); |
| 192 | if (!handle) { |
| 193 | throw new Error("Cross-origin storage API returned no handle."); |
| 194 | } |
| 195 | const writableStream = await handle.createWritable(); |
| 196 | await writableStream.write(blob); |
| 197 | await writableStream.close(); |
| 198 | this.hashCache.set(url, hash); |
| 199 | await this.persistHashEntry(url, hash); |
| 200 | } |
| 201 | |
| 202 | async delete(_request: RequestLike): Promise<void> { |
| 203 | // Cross-origin storage extension currently has no delete API. |
no test coverage detected