Ejemplo n.º 1
0
  @Override
  public boolean save(final String path, final File file) {

    if (!isAvailable()) {
      return false;
    }

    try {

      final AmazonS3Client client = amazonConfig.client();
      final String bucket = amazonConfig.bucket();

      final PutObjectRequest request = //
          new PutObjectRequest(bucket, Util.rootLessPath(path), file);

      final PutObjectResult result = client.putObject(request);

      return true;

    } catch (final Exception e) {

      log.error("bada-boom", e);

      setAvailable(false);

      return false;
    }
  }
Ejemplo n.º 2
0
  @Override
  public boolean kill(final String path) {

    if (!isAvailable()) {
      return false;
    }

    try {

      final AmazonS3Client client = amazonConfig.client();
      final String bucket = amazonConfig.bucket();

      final DeleteObjectRequest request = //
          new DeleteObjectRequest(bucket, Util.rootLessPath(path));

      client.deleteObject(request);

      return true;

    } catch (final Exception e) {

      log.error("bada-boom", e);

      setAvailable(false);

      return false;
    }
  }