Importig an Asset from Amazon S3

import com.amazonaws.auth.EnvironmentVariableCredentialsProvider;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.model.CopyObjectRequest;
import com.amazonaws.services.s3.model.CopyObjectResult;
import io.impossible.fx.assets.FXAssetManagementClient;
import io.impossible.fx.assets.S3ImportContext;
import io.impossible.fx.assets.S3ImportStatus;
import io.impossible.fx.auth.StaticCredentialsProvider;
import io.impossible.fx.assets.model.CreateProjectResponse;

fxClient = FXAssetManagementClient.builder()
    .withRegion(Regions.EU_WEST_1)
    .build();

s3Client = AmazonS3ClientBuilder.standard()
    .withCredentials(new EnvironmentVariableCredentialsProvider())
    .build();

S3ImportContext ctx = fxClient.prepareS3Import(prjuid, "test.mp4");

CopyObjectRequest copy = new CopyObjectRequest("source-bucket", "source-file.mp4", ctx.getBucket(), ctx.getKey());

s3Client.copyObject(copy);
fxClient.S3Import(ctx);

while(fxClient.getS3ImportResult(ctx) != S3ImportStatus.FINISHED) {
    System.out.println("Still importing...");
    Thread.sleep(1000);
}

System.out.println("Import finished: " + fxClient.getS3ImportResult(ctx));

Terms of Use | © 2017, Impossible Software, or its affiliates. All rights reserved.