mock-aws-s3 icon indicating copy to clipboard operation
mock-aws-s3 copied to clipboard

copyObject is returning /tmp/buckets//<bucket_name>/key

Open jcald1 opened this issue 4 years ago • 0 comments

I'm running v 4.0.1

copyObject is returning /tmp/buckets//<bucket_name>/key

Code: const copyObject = s3 => sourceBucket => outputBucket => ( oldKey, newKey) => {

  const CopySource = `/${sourceBucket}/${oldKey}`;
  const params = {
    Bucket : outputBucket,
    CopySource,
    Key    : newKey
  };
  return s3.copyObject(params).promise();

test file:

const AWSMock = require('mock-aws-s3');

AWSMock.config.basePath = '/tmp/buckets';

const FAKE_S3 = AWSMock.S3({ params : { Bucket : KNOWN_OUTPUT_BUCKET } }), FAKE_OLD_KEY = 'oldkey', FAKE_NEW_KEY = 'newkey', FAKE_BODY = '123';

copyObject(FAKE_S3)(KNOWN_OUTPUT_BUCKET)(KNOWN_OUTPUT_BUCKET)(FAKE_OLD_KEY, FAKE_NEW_KEY) .then(res => { console.log('res',res)


Output:

res { Bucket: '/tmp/buckets/media-output-dev-use1-v1', CopySource: '/tmp/buckets//media-output-dev-use1-v1/oldkey', Key: 'newkey' }

jcald1 avatar Apr 24 '20 21:04 jcald1