Package org.jets3t.service.model

Examples of org.jets3t.service.model.S3Object


    }
  }

  public void storeLargeFile(String key, File file, byte[] md5Hash)
      throws IOException {
    S3Object object = new S3Object(key);
    object.setDataInputFile(file);
    object.setContentType("binary/octet-stream");
    object.setContentLength(file.length());
    object.setServerSideEncryptionAlgorithm(serverSideEncryptionAlgorithm);
    if (md5Hash != null) {
      object.setMd5Hash(md5Hash);
    }

    List<StorageObject> objectsToUploadAsMultipart =
        new ArrayList<StorageObject>();
    objectsToUploadAsMultipart.add(object);
View Full Code Here


  }
 
  @Override
  public void storeEmptyFile(String key) throws IOException {
    try {
      S3Object object = new S3Object(key);
      object.setDataInputStream(new ByteArrayInputStream(new byte[0]));
      object.setContentType("binary/octet-stream");
      object.setContentLength(0);
      object.setServerSideEncryptionAlgorithm(serverSideEncryptionAlgorithm);
      s3Service.putObject(bucket, object);
    } catch (ServiceException e) {
      handleException(e, key);
    }
  }
View Full Code Here

  @Override
  public InputStream retrieve(String key) throws IOException {
    try {
      LOG.debug("Getting key: {} from bucket: {}",
          key, bucket.getName());
      S3Object object = s3Service.getObject(bucket.getName(), key);
      return object.getDataInputStream();
    } catch (ServiceException e) {
      handleException(e, key);
      return null; //return null if key not found
    }
  }
View Full Code Here

  public InputStream retrieve(String key, long byteRangeStart)
          throws IOException {
    try {
      LOG.debug("Getting key: {} from bucket: {} with byteRangeStart: {}",
          key, bucket.getName(), byteRangeStart);
      S3Object object = s3Service.getObject(bucket, key, null, null, null,
                                            null, byteRangeStart, null);
      return object.getDataInputStream();
    } catch (ServiceException e) {
      handleException(e, key);
      return null;
    }
  }
View Full Code Here

    }
  }

  public void rename(String srcKey, String dstKey) throws IOException {
    try {
      s3Service.renameObject(bucket.getName(), srcKey, new S3Object(dstKey));
    } catch (ServiceException e) {
      handleException(e, srcKey);
    }
  }
View Full Code Here

    try {
      if(LOG.isDebugEnabled()) {
        LOG.debug("Copying srcKey: " + srcKey + "to dstKey: " + dstKey + "in bucket: " + bucket.getName());
      }
      if (multipartEnabled) {
        S3Object object = s3Service.getObjectDetails(bucket, srcKey, null,
                                                     null, null, null);
        if (multipartCopyBlockSize > 0 &&
            object.getContentLength() > multipartCopyBlockSize) {
          copyLargeFile(object, dstKey);
          return;
        }
      }

      S3Object dstObject = new S3Object(dstKey);
      dstObject.setServerSideEncryptionAlgorithm(serverSideEncryptionAlgorithm);
      s3Service.copyObject(bucket.getName(), srcKey, bucket.getName(),
          dstObject, false);
    } catch (ServiceException e) {
      handleException(e, srcKey);
    }
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
View Full Code Here

          index = filePath.lastIndexOf('\\');
        }
        fileName = filePath.substring(index + 1, filePath.length());
        System.out.println(filePath);
        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.getErrorWindow().info(S3Uploader.this.parent, "", "Uploaded successfully!");
                       
            //add key to S3Tree
View Full Code Here

        try {
            AWSCredentials credentials = new AWSCredentials(s3AccessKey, s3SecretKey);
            S3Service s3 = new RestS3Service(credentials);
            S3Bucket bucket = s3.getBucket("xubu");
            File file = flv.getFile();
            S3Object object = new S3Object(bucket, file);
            AccessControlList acl = s3.getBucketAcl(bucket);
            object.setAcl(acl);
            object.setKey("streams/" + stream_id + ".flv");
            object = s3.putObject(bucket, object);
            log.info("http://s3.amazonaws.com/" + bucket.getName() + "/" + object.getKey());
            file.delete();
            return true;
        } catch (IOException e) {
            log.error(e);
            return false;
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

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.