| 33 | |
| 34 | return { |
| 35 | async save(input: DestinationSaveInput, context): Promise<DestinationSaveResult> { |
| 36 | if (!context.artifacts) { |
| 37 | throw new ConfigurationError( |
| 38 | 'Artifact service is not available in this execution context. Enable artifact storage to use this destination.', |
| 39 | { configKey: 'artifacts' }, |
| 40 | ); |
| 41 | } |
| 42 | |
| 43 | const normalized = |
| 44 | destinations.length > 0 ? destinations : (['run'] as ArtifactDestination[]); |
| 45 | |
| 46 | const upload = await context.artifacts.upload({ |
| 47 | name: input.fileName, |
| 48 | mimeType: input.mimeType, |
| 49 | content: input.buffer, |
| 50 | destinations: normalized, |
| 51 | metadata: input.metadata, |
| 52 | }); |
| 53 | |
| 54 | return { |
| 55 | artifactId: upload.artifactId, |
| 56 | destinations: normalized, |
| 57 | }; |
| 58 | }, |
| 59 | }; |
| 60 | }, |
| 61 | }; |