@@ -5,11 +5,18 @@ import {
5
5
} from '@aws-sdk/client-s3' ;
6
6
import { RequestPresigningArguments } from '@aws-sdk/types' ;
7
7
import { Type } from '@nestjs/common' ;
8
+ import { MaybeAsync } from '@seedcompany/common' ;
8
9
import { Command } from '@smithy/smithy-client' ;
9
10
import { NodeJsRuntimeStreamingBlobPayloadInputTypes } from '@smithy/types/dist-types/streaming-payload/streaming-blob-payload-input-types' ;
10
11
import { Readable } from 'stream' ;
11
- import { Except , Merge , SetNonNullable , SetRequired } from 'type-fest' ;
12
- import { DurationIn } from '~/common' ;
12
+ import {
13
+ Except ,
14
+ LiteralUnion ,
15
+ Merge ,
16
+ SetNonNullable ,
17
+ SetRequired ,
18
+ } from 'type-fest' ;
19
+ import { DurationIn , InputException , InputExceptionArgs } from '~/common' ;
13
20
14
21
// Limit body to only `Readable` which is always the case for Nodejs execution.
15
22
export type GetObjectOutput = Merge < AwsGetObjectOutput , { Body : Readable } > ;
@@ -41,6 +48,10 @@ export abstract class FileBucket {
41
48
operation : Type < Command < TCommandInput , any , any > > ,
42
49
input : SignedOp < TCommandInput > ,
43
50
) : Promise < string > ;
51
+ abstract parseSignedUrl ( url : URL ) : MaybeAsync < {
52
+ Key : string ;
53
+ operation : LiteralUnion < 'PutObject' | 'GetObject' , string > ;
54
+ } > ;
44
55
45
56
abstract getObject ( key : string ) : Promise < GetObjectOutput > ;
46
57
abstract headObject ( key : string ) : Promise < HeadObjectOutput > ;
@@ -52,3 +63,9 @@ export abstract class FileBucket {
52
63
await this . deleteObject ( oldKey ) ;
53
64
}
54
65
}
66
+
67
+ export class InvalidSignedUrlException extends InputException {
68
+ constructor ( ...args : InputExceptionArgs ) {
69
+ super ( ...InputException . parseArgs ( 'Invalid signed URL' , args ) ) ;
70
+ }
71
+ }
0 commit comments