use of com.amplifyframework.storage.s3.service.StorageService in project amplify-android by aws-amplify.
the class AWSS3StoragePlugin method uploadInputStream.
@NonNull
@Override
public StorageUploadInputStreamOperation<?> uploadInputStream(@NonNull String key, @NonNull InputStream local, @NonNull StorageUploadInputStreamOptions options, @NonNull Consumer<StorageTransferProgress> onProgress, @NonNull Consumer<StorageUploadInputStreamResult> onSuccess, @NonNull Consumer<StorageException> onError) {
AWSS3StorageUploadRequest<InputStream> request = new AWSS3StorageUploadRequest<>(key, local, options.getAccessLevel() != null ? options.getAccessLevel() : defaultAccessLevel, options.getTargetIdentityId(), options.getContentType(), options instanceof AWSS3StorageUploadInputStreamOptions ? ((AWSS3StorageUploadInputStreamOptions) options).getServerSideEncryption() : ServerSideEncryption.NONE, options.getMetadata());
AWSS3StorageUploadInputStreamOperation operation = new AWSS3StorageUploadInputStreamOperation(storageService, cognitoAuthProvider, request, awsS3StoragePluginConfiguration, onProgress, onSuccess, onError);
operation.start();
return operation;
}
use of com.amplifyframework.storage.s3.service.StorageService in project amplify-android by aws-amplify.
the class AWSS3StoragePlugin method list.
@NonNull
@Override
public StorageListOperation<?> list(@NonNull String path, @NonNull StorageListOptions options, @NonNull Consumer<StorageListResult> onSuccess, @NonNull Consumer<StorageException> onError) {
AWSS3StorageListRequest request = new AWSS3StorageListRequest(path, options.getAccessLevel() != null ? options.getAccessLevel() : defaultAccessLevel, options.getTargetIdentityId());
AWSS3StorageListOperation operation = new AWSS3StorageListOperation(storageService, executorService, cognitoAuthProvider, request, awsS3StoragePluginConfiguration, onSuccess, onError);
operation.start();
return operation;
}
use of com.amplifyframework.storage.s3.service.StorageService in project amplify-android by aws-amplify.
the class AWSS3StoragePlugin method getUrl.
@NonNull
@Override
public StorageGetUrlOperation<?> getUrl(@NonNull String key, @NonNull StorageGetUrlOptions options, @NonNull Consumer<StorageGetUrlResult> onSuccess, @NonNull Consumer<StorageException> onError) {
AWSS3StorageGetPresignedUrlRequest request = new AWSS3StorageGetPresignedUrlRequest(key, options.getAccessLevel() != null ? options.getAccessLevel() : defaultAccessLevel, options.getTargetIdentityId(), options.getExpires() != 0 ? options.getExpires() : defaultUrlExpiration);
AWSS3StorageGetPresignedUrlOperation operation = new AWSS3StorageGetPresignedUrlOperation(storageService, executorService, cognitoAuthProvider, request, awsS3StoragePluginConfiguration, onSuccess, onError);
operation.start();
return operation;
}
use of com.amplifyframework.storage.s3.service.StorageService in project amplify-android by aws-amplify.
the class AWSS3StoragePlugin method downloadFile.
@NonNull
@Override
public StorageDownloadFileOperation<?> downloadFile(@NonNull String key, @NonNull File local, @NonNull StorageDownloadFileOptions options, @NonNull Consumer<StorageTransferProgress> onProgress, @NonNull Consumer<StorageDownloadFileResult> onSuccess, @NonNull Consumer<StorageException> onError) {
AWSS3StorageDownloadFileRequest request = new AWSS3StorageDownloadFileRequest(key, local, options.getAccessLevel() != null ? options.getAccessLevel() : defaultAccessLevel, options.getTargetIdentityId());
AWSS3StorageDownloadFileOperation operation = new AWSS3StorageDownloadFileOperation(storageService, cognitoAuthProvider, request, awsS3StoragePluginConfiguration, onProgress, onSuccess, onError);
operation.start();
return operation;
}
use of com.amplifyframework.storage.s3.service.StorageService in project amplify-android by aws-amplify.
the class StorageComponentTest method setup.
/**
* Sets up Storage category by registering a mock AWSS3StoragePlugin
* instance to Amplify and configuring.
*
* @throws AmplifyException if Amplify fails to configure with mock
* Storage category configuration.
*/
@Before
public void setup() throws AmplifyException {
this.storage = new StorageCategory();
this.storageService = mock(StorageService.class);
StorageService.Factory storageServiceFactory = (context, region, bucket) -> storageService;
CognitoAuthProvider cognitoAuthProvider = mock(CognitoAuthProvider.class);
doReturn(RandomString.string()).when(cognitoAuthProvider).getIdentityId();
this.storage.addPlugin(new AWSS3StoragePlugin(storageServiceFactory, cognitoAuthProvider, new AWSS3StoragePluginConfiguration.Builder().build()));
this.storage.configure(buildConfiguration(), getApplicationContext());
this.storage.initialize(getApplicationContext());
}
Aggregations