(packet: IOPacket, span?: Span)
| 160 | } |
| 161 | |
| 162 | async function importPacket(packet: IOPacket, span?: Span): Promise<IOPacket> { |
| 163 | if (!packet.data) { |
| 164 | return packet; |
| 165 | } |
| 166 | |
| 167 | if (!apiClientManager.client) { |
| 168 | return packet; |
| 169 | } |
| 170 | |
| 171 | const presignedResponse = await apiClientManager.client.getPayloadUrl(packet.data); |
| 172 | |
| 173 | const response = await fetch(presignedResponse.presignedUrl); |
| 174 | |
| 175 | if (!response.ok) { |
| 176 | throw new Error( |
| 177 | `Failed to import packet ${presignedResponse.presignedUrl}: ${response.statusText}` |
| 178 | ); |
| 179 | } |
| 180 | |
| 181 | const data = await response.text(); |
| 182 | |
| 183 | span?.setAttribute("size", Buffer.byteLength(data, "utf8")); |
| 184 | |
| 185 | return { |
| 186 | data, |
| 187 | dataType: response.headers.get("content-type") ?? "application/json", |
| 188 | }; |
| 189 | |
| 190 | return packet; |
| 191 | } |
| 192 | |
| 193 | export async function createPacketAttributes( |
| 194 | packet: IOPacket, |
no test coverage detected
searching dependent graphs…