Package org.jets3t.service.model

Examples of org.jets3t.service.model.S3Object


                if (index == -1) {
                    index = filePath.lastIndexOf('\\');
                }
                fileName = filePath.substring(index + 1, filePath.length());
                try {
                    S3Object s3Object = new S3Object(new File(filePath));
                    s3.putObject(bucket, s3Object);

                    /*
                     * We cannot cancel during upload, so delete file instead
                     */
                    if (S3Uploader.this.canceled) {
                        s3.deleteObject(bucket, s3Object.getKey());
                    } else {

                        S3Uploader.this.engine.getGUI().getErrorWindow().info(S3Uploader.this.parent, "",
                                "Uploaded successfully!");

View Full Code Here


    return true;
  }

  private InputStream get(String key) throws IOException {
    try {
      S3Object object = s3Service.getObject(bucket, key);
      return object.getDataInputStream();
    } catch (S3ServiceException e) {
      if (e.getS3ErrorCode().equals("NoSuchKey")) {
        return null;
      }
      if (e.getCause() instanceof IOException) {
View Full Code Here

    }
  }

  private InputStream get(String key, long byteRangeStart) throws IOException {
    try {
      S3Object object = s3Service.getObject(bucket, key, null, null, null,
          null, byteRangeStart, null);
      return object.getDataInputStream();
    } catch (S3ServiceException e) {
      if (e.getS3ErrorCode().equals("NoSuchKey")) {
        return null;
      }
      if (e.getCause() instanceof IOException) {
View Full Code Here

    }   
  }

  private void put(String key, InputStream in, long length) throws IOException {
    try {
      S3Object object = new S3Object(key);
      object.setDataInputStream(in);
      object.setContentType("binary/octet-stream");
      object.setContentLength(length);
      s3Service.putObject(bucket, object);
    } catch (S3ServiceException e) {
      if (e.getCause() instanceof IOException) {
        throw (IOException) e.getCause();
      }
View Full Code Here

    return true;
  }

  private InputStream get(String key) throws IOException {
    try {
      S3Object object = s3Service.getObject(bucket, key);
      return object.getDataInputStream();
    } catch (S3ServiceException e) {
      if (e.getErrorCode().equals("NoSuchKey")) {
        return null;
      }
      if (e.getCause() instanceof IOException) {
View Full Code Here

    }
  }

  private InputStream get(String key, long byteRangeStart) throws IOException {
    try {
      S3Object object = s3Service.getObject(bucket, key, null, null, null,
          null, byteRangeStart, null);
      return object.getDataInputStream();
    } catch (S3ServiceException e) {
      if (e.getErrorCode().equals("NoSuchKey")) {
        return null;
      }
      if (e.getCause() instanceof IOException) {
View Full Code Here

    }
  }

  private void put(String key, InputStream in, long length) throws IOException {
    try {
      S3Object object = new S3Object(key);
      object.setDataInputStream(in);
      object.setContentType("binary/octet-stream");
      object.setContentLength(length);
      s3Service.putObject(bucket, object);
    } catch (S3ServiceException e) {
      if (e.getCause() instanceof IOException) {
        throw (IOException) e.getCause();
      }
View Full Code Here

            public void run() {

                BufferedWriter out = null;
                BufferedReader in = null;
                try {
                    S3Object s3Object = s3.getObject(bucket, key);

                    File fileOut = new File(directory + File.separator + s3Object.getKey());
                    if (!fileOut.getParentFile().exists()) {
                        fileOut.getParentFile().mkdirs();
                    }
                    if (!fileOut.exists()) {
                        fileOut.createNewFile();
                    }

                    out = new BufferedWriter(new FileWriter(fileOut));
                    in = new BufferedReader(new InputStreamReader(s3Object.getDataInputStream()));
                    String data = null;
                    while ((data = in.readLine()) != null) {

                        // stop download and delete file
                        if (S3Downloader.this.canceled) {
View Full Code Here

                if (index == -1) {
                    index = filePath.lastIndexOf('\\');
                }
                fileName = filePath.substring(index + 1, filePath.length());
                try {
                    S3Object s3Object = new S3Object(new File(filePath));
                    s3.putObject(bucket, s3Object);

                    /*
                     * We cannot cancel during upload, so delete file instead
                     */
                    if (S3Uploader.this.canceled) {
                        s3.deleteObject(bucket, s3Object.getKey());
                    } else {

                        S3Uploader.this.engine.getGUI().getErrorWindow().info(S3Uploader.this.parent, "",
                                "Uploaded successfully!");

View Full Code Here

  private InputStream get(String key, boolean checkMetadata)
      throws IOException {
   
    try {
      S3Object object = s3Service.getObject(bucket, key);
      if (checkMetadata) {
        checkMetadata(object);
      }
      return object.getDataInputStream();
    } catch (S3ServiceException e) {
      if ("NoSuchKey".equals(e.getS3ErrorCode())) {
        return null;
      }
      if (e.getCause() instanceof IOException) {
View Full Code Here

TOP

Related Classes of org.jets3t.service.model.S3Object

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.