(command)
| 6 | } |
| 7 | |
| 8 | async send(command) { |
| 9 | const commandName = command.constructor.name; |
| 10 | const input = command.input; |
| 11 | |
| 12 | switch (commandName) { |
| 13 | case 'HeadBucketCommand': |
| 14 | return {}; |
| 15 | case 'GetBucketVersioningCommand': |
| 16 | if (this.versioning) { |
| 17 | return { Status: 'Enabled' }; |
| 18 | } |
| 19 | return {}; |
| 20 | case 'HeadObjectCommand': |
| 21 | return { |
| 22 | ContentLength: 1024 * 1024 * 1024, |
| 23 | }; |
| 24 | case 'CompleteMultipartUploadCommand': { |
| 25 | const retObj = { |
| 26 | Bucket: input.Bucket, |
| 27 | Key: input.Key, |
| 28 | ETag: `"${uuidv4().replace(/-/g, '')}"`, |
| 29 | ContentLength: 1024 * 1024 * 1024, |
| 30 | }; |
| 31 | if (this.versioning) { |
| 32 | retObj.VersionId = uuidv4().replace(/-/g, ''); |
| 33 | } |
| 34 | return retObj; |
| 35 | } |
| 36 | case 'PutObjectCommand': { |
| 37 | const retObj = { |
| 38 | ETag: `"${uuidv4().replace(/-/g, '')}"`, |
| 39 | }; |
| 40 | if (this.versioning) { |
| 41 | retObj.VersionId = uuidv4().replace(/-/g, ''); |
| 42 | } |
| 43 | return retObj; |
| 44 | } |
| 45 | case 'CopyObjectCommand': { |
| 46 | const retObj = { |
| 47 | CopyObjectResult: { |
| 48 | ETag: `"${uuidv4().replace(/-/g, '')}"`, |
| 49 | LastModified: new Date().toISOString(), |
| 50 | }, |
| 51 | VersionId: null, |
| 52 | }; |
| 53 | if (this.versioning) { |
| 54 | retObj.VersionId = uuidv4().replace(/-/g, ''); |
| 55 | } |
| 56 | return retObj; |
| 57 | } |
| 58 | default: |
| 59 | throw new Error(`Unsupported command: ${commandName}`); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | // Legacy SDK v2 callback-based interface (for backwards compatibility) |
| 64 | headBucket(params, callback) { |
no outgoing calls
no test coverage detected