Package org.jets3t.service.model

Examples of org.jets3t.service.model.S3Object


                    result = s3Object;
                } else {
                    SignedUrlHandler handler = (SignedUrlHandler) s3Service;
                    handler.putObjectAclWithSignedUrl(signedUrl, signedUrlAcl);
                    URL url = new URL(signedUrl);
                    S3Object object = ServiceUtils.buildObjectFromUrl(url.getHost(), url.getPath());
                    object.setAcl(signedUrlAcl);
                    result = object;                   
                }
            } catch (RuntimeException e) {
                result = e;
                throw e;
View Full Code Here


     * @throws S3ServiceException
     */
    public S3Object[] getObjects(final S3Bucket bucket, final String[] objectKeys) throws S3ServiceException {
        S3Object[] objects = new S3Object[objectKeys.length];
        for (int i = 0; i < objectKeys.length; i++) {
            objects[i] = new S3Object(objectKeys[i]);
        }
        return getObjects(bucket, objects);
    }
View Full Code Here

     * exceptions could include IO failures, gzipping and encryption failures.
     */
    public static S3Object createObjectForUpload(String objectKey, File dataFile,
        EncryptionUtil encryptionUtil, boolean gzipFile, BytesProgressWatcher progressWatcher) throws Exception
    {
        S3Object s3Object = new S3Object(objectKey);
       
        // Set object explicitly to private access by default.
        s3Object.setAcl(AccessControlList.REST_CANNED_PRIVATE);
       
        s3Object.addMetadata(Constants.METADATA_JETS3T_LOCAL_FILE_DATE,
            ServiceUtils.formatIso8601Date(new Date(dataFile.lastModified())));

        if (dataFile.isDirectory()) {
            s3Object.setContentLength(0);
            s3Object.setContentType(Mimetypes.MIMETYPE_JETS3T_DIRECTORY);
        } else {
            s3Object.setContentType(Mimetypes.getInstance().getMimetype(dataFile));
            File uploadFile = transformUploadFile(dataFile, s3Object, encryptionUtil,
                gzipFile, progressWatcher);
            s3Object.setContentLength(uploadFile.length());
            s3Object.setDataInputFile(uploadFile);
           
            // Compute the upload file's MD5 hash.
            InputStream inputStream = new BufferedInputStream(new FileInputStream(uploadFile));
            if (progressWatcher != null) {
                inputStream = new ProgressMonitoredInputStream(inputStream, progressWatcher);
            }
            s3Object.setMd5Hash(ServiceUtils.computeMD5Hash(inputStream));
           
            if (!uploadFile.equals(dataFile)) {
                // Compute the MD5 hash of the *original* file, if upload file has been altered
                // through encryption or gzipping.
                inputStream = new BufferedInputStream(new FileInputStream(dataFile));
                if (progressWatcher != null) {
                    inputStream = new ProgressMonitoredInputStream(inputStream, progressWatcher);
                }               
               
                s3Object.addMetadata(
                    S3Object.METADATA_HEADER_ORIGINAL_HASH_MD5,
                    ServiceUtils.toBase64(ServiceUtils.computeMD5Hash(inputStream)));
            }           
        }
        return s3Object;
View Full Code Here

     * objects reconstructed from the provided signature requests.
     */
    public S3Object[] buildS3ObjectsFromSignatureRequests(SignatureRequest[] srs) {
      S3Object[] objects = new S3Object[srs.length];
      for (int i = 0; i < srs.length; i++) {
        objects[i] = new S3Object(srs[i].getObjectKey());
        objects[i].addAllMetadata(srs[i].getObjectMetadata());
      }
      return objects;
    }
View Full Code Here

            }
           
            // Generate URLs
            StringBuffer signedUrlsBuffer = new StringBuffer();
            for (int i = 0; i < objects.length; i++) {
                S3Object currentObject = objects[i];

                String signedUrl = S3Service.createSignedUrl("GET",
                    currentObject.getBucketName(), currentObject.getKey(), specialParamName,
                    null, this.s3Service.getAWSCredentials(), secondsSinceEpoch,
                    virtualHostCheckBox.isSelected(), httpsUrlsCheckBox.isSelected());
               
                signedUrlsBuffer.append(signedUrl + "\n");
            }
View Full Code Here

            int objectIndex = 0;
            for (Iterator iter = fileKeysForUpload.iterator(); iter.hasNext();) {
                String fileKey = iter.next().toString();
                File file = (File) uploadingFilesMap.get(fileKey);
                                               
                S3Object newObject = ObjectUtils
                    .createObjectForUpload(fileKey, file, null, false, progressWatcher);
                               
                statusText[0] = "Prepared " + (objectIndex + 1)
                    + " of " + fileKeysForUpload.size() + " file(s) for upload";
               
View Full Code Here

        if (objects.length != 1) {
            log.warn("Ignoring Generate Public URL object command, can only operate on a single object");
            return;           
        }
        S3Object currentObject = objects[0];

        try {
          String url = "http://"
            + (userVanityHost != null? userVanityHost + "/" : Constants.S3_HOSTNAME + "/" + userBucketName + "/")
            + userPath + currentObject.getKey();
         
            // Display signed URL
            String dialogText = "Public URL for '" + currentObject.getKey() + "'.";
            // Ensure dialog text is at least 150 characters (to force dialog to be wider)
            if (dialogText.length() < 150) {
                int charsShort = 150 - dialogText.length();
                StringBuffer padding = new StringBuffer();
                for (int i = 0; i < charsShort / 2; i++) {
View Full Code Here

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    synchronized (s3ServiceMulti) {
                        // Retain selected status of objects for downloads or properties
                        for (int i = 0; i < event.getCompletedObjects().length; i++) {
                            S3Object object = event.getCompletedObjects()[i];
                            int modelIndex = objectTableModel.addObject(object);
                            log.debug("Updated table with " + object.getKey() + ", content-type=" + object.getContentType());
   
                            if (isDownloadingObjects) {
                                s3DownloadObjectsMap.put(object.getKey(), object);
                                log.debug("Updated object download list with " + object.getKey()
                                    + ", content-type=" + object.getContentType());
                            } else if (isUploadingFiles) {
                                s3ExistingObjectsMap.put(object.getKey(), object);
                                log.debug("Updated object upload list with " + object.getKey()
                                    + ", content-type=" + object.getContentType());                           
                            }
                           
                            int viewIndex = objectTableModelSorter.viewIndex(modelIndex);
                            if (isDownloadingObjects || isViewingObjectProperties) {
                                objectsTable.addRowSelectionInterval(viewIndex, viewIndex);
View Full Code Here

                    public void run() {
                        progressDialog.startDialog("Downloading your AWS Credentials", "", 0, 0, null, null);
                    }
                 });
               
                S3Object encryptedCredentialsObject = null;

                try {
                    S3Service s3Service = new RestS3Service(null);       
                    encryptedCredentialsObject = s3Service.getObject(
                        new S3Bucket(bucketName[0]), credentialObjectKey[0]);
                } catch (S3ServiceException e) {
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            progressDialog.stopDialog();
                        }
                     });

                    String errorMessage = "<html><center>Unable to find your AWS Credentials in S3"
                        + "<br><br>Please check your passphrase and password</center></html>";
                    log.error(errorMessage, e);
                    ErrorDialog.showDialog(myself, hyperlinkListener, errorMessage, null);
                    return;
                }
               
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        progressDialog.updateDialog("Decrypting your AWS Credentials", null, 0);
                    }
                 });
               
                try {
                    myself.awsCredentials = AWSCredentials.load(password,
                        new BufferedInputStream(encryptedCredentialsObject.getDataInputStream()));
                   
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            progressDialog.stopDialog();
                        }
View Full Code Here

                    }
                 });

                try {
                    S3Bucket bucket = new S3Bucket(bucketName[0]);
                    S3Object encryptedCredentialsObject = new S3Object(credentialObjectKey[0]);       
                    encryptedCredentialsObject.setDataInputStream(bais[0]);
                    encryptedCredentialsObject.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ);
                   
                    // Store credentials
                    S3Service s3Service = new RestS3Service(awsCredentials);
                    s3Service.createBucket(bucketName[0]);           
                    s3Service.putObject(bucket, encryptedCredentialsObject);
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.