(packet: IOPacket, pathPrefix: string)
| 105 | } |
| 106 | |
| 107 | async function exportPacket(packet: IOPacket, pathPrefix: string): Promise<IOPacket> { |
| 108 | // Offload the output |
| 109 | const filename = `${pathPrefix}.${getPacketExtension(packet.dataType)}`; |
| 110 | |
| 111 | const presignedResponse = await apiClientManager.client!.createUploadPayloadUrl(filename); |
| 112 | |
| 113 | const uploadResponse = await fetch(presignedResponse.presignedUrl, { |
| 114 | method: "PUT", |
| 115 | headers: { |
| 116 | "Content-Type": packet.dataType, |
| 117 | }, |
| 118 | body: packet.data, |
| 119 | }); |
| 120 | |
| 121 | if (!uploadResponse.ok) { |
| 122 | throw new Error( |
| 123 | `Failed to upload output to ${presignedResponse.presignedUrl}: ${uploadResponse.statusText}` |
| 124 | ); |
| 125 | } |
| 126 | |
| 127 | return { |
| 128 | data: filename, |
| 129 | dataType: "application/store", |
| 130 | }; |
| 131 | |
| 132 | return packet; |
| 133 | } |
| 134 | |
| 135 | export async function conditionallyImportPacket( |
| 136 | packet: IOPacket, |
no test coverage detected
searching dependent graphs…