-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added a new command-mode command for storing object in the arte…
…fact store. (#4) * feat: added put object in artifact store command
- Loading branch information
1 parent
cdc2d6f
commit 9cefd75
Showing
5 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/se/attini/runner/commandmode/ArtifactStoreFacade.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package se.attini.runner.commandmode; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import java.nio.file.Path; | ||
import javax.enterprise.context.ApplicationScoped; | ||
|
||
import se.attini.runner.BeanFactory; | ||
import se.attini.runner.EnvironmentVariables; | ||
import software.amazon.awssdk.core.sync.RequestBody; | ||
import software.amazon.awssdk.services.s3.S3Client; | ||
import software.amazon.awssdk.services.s3.model.PutObjectRequest; | ||
|
||
@ApplicationScoped | ||
public class ArtifactStoreFacade { | ||
|
||
private final S3Client s3Client; | ||
private final EnvironmentVariables environmentVariables; | ||
|
||
public ArtifactStoreFacade(@BeanFactory.CustomAwsClient S3Client s3Client, EnvironmentVariables environmentVariables) { | ||
this.s3Client = requireNonNull(s3Client, "s3Client"); | ||
this.environmentVariables = environmentVariables; | ||
} | ||
|
||
|
||
public void store(String key, String path){ | ||
s3Client.putObject(PutObjectRequest.builder().key(key).bucket(environmentVariables.getArtifactStoreBucketName()).build(), | ||
RequestBody.fromFile(Path.of(path))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters