AwsS3AssetStore extends AwsAbstractArchive implements RemoteAssetStore { protected InputStream getObject(AwsAssetMapping map) { S3Object object = s3.getObject(bucketName, map.getObjectKey()); return object.getObjectContent(); }  @Override @Reference(name = "workspace") void setWorkspace(Workspace workspace); @Override @Reference(name = "database") void setDatabase(AwsAssetDatabase db); @Activate void activate(final ComponentContext cc); String getBucketName(); static final String AWS_S3_ENABLED; static final String AWS_S3_ACCESS_KEY_ID_CONFIG; static final String AWS_S3_SECRET_ACCESS_KEY_CONFIG; static final String AWS_S3_REGION_CONFIG; static final String AWS_S3_BUCKET_CONFIG; static final String AWS_S3_ENDPOINT_CONFIG; static final String AWS_S3_PATH_STYLE_CONFIG; }
@Test public void testPut() throws Exception { Upload upload = EasyMock.createStrictMock(Upload.class); upload.waitForCompletion(); EasyMock.expectLastCall().once(); EasyMock.replay(upload); EasyMock.expect(s3Transfer.upload(BUCKET_NAME, KEY_VERSION_1 + ASSET_ID + ".xml", sampleFile)).andReturn(upload); EasyMock.expect(s3Client.getObject(BUCKET_NAME, KEY_VERSION_1 + ASSET_ID + ".xml")).andReturn(s3Object); EasyMock.replay(s3Object, s3Client, s3Transfer); StoragePath path = new StoragePath(ORG_ID, MP_ID, new VersionImpl(1L), ASSET_ID); store.put(path, Source.mk(uri)); AwsAssetMapping mapping = database.findMapping(path); Assert.assertNotNull(mapping); Assert.assertEquals(ORG_ID, mapping.getOrganizationId()); Assert.assertEquals(MP_ID, mapping.getMediaPackageId()); Assert.assertEquals(1L, mapping.getVersion().longValue()); Assert.assertEquals(ASSET_ID, mapping.getMediaPackageElementId()); }
@Test public void testGet() throws Exception { Upload upload = EasyMock.createStrictMock(Upload.class); upload.waitForCompletion(); EasyMock.expectLastCall().once(); EasyMock.replay(upload); EasyMock.expect(s3Transfer.upload(BUCKET_NAME, KEY_VERSION_1 + ASSET_ID + ".xml", sampleFile)).andReturn(upload); S3ObjectInputStream s3Stream = EasyMock.createNiceMock(S3ObjectInputStream.class); EasyMock.expect(s3Object.getObjectContent()).andReturn(s3Stream); EasyMock.expect(s3Client.getObject(BUCKET_NAME, KEY_VERSION_1 + ASSET_ID + ".xml")).andReturn(s3Object); EasyMock.replay(s3Object, s3Stream, s3Client, s3Transfer); StoragePath path = new StoragePath(ORG_ID, MP_ID, new VersionImpl(1L), ASSET_ID); store.put(path, Source.mk(uri)); Opt<InputStream> streamOpt = store.get(path); Assert.assertTrue(streamOpt.isSome()); }