List of usage examples for com.amazonaws.services.s3.model S3Object getObjectContent
public S3ObjectInputStream getObjectContent()
From source file:ch.myniva.gradle.caching.s3.internal.AwsS3BuildCacheService.java
License:Apache License
@Override public boolean load(BuildCacheKey key, BuildCacheEntryReader reader) { final String bucketPath = getBucketPath(key); if (s3.doesObjectExist(bucketName, bucketPath)) { logger.info("Found cache item '{}' in S3 bucket", bucketPath); S3Object object = s3.getObject(bucketName, bucketPath); try (InputStream is = object.getObjectContent()) { reader.readFrom(is);/*from w w w .j av a 2 s .c om*/ return true; } catch (IOException e) { throw new BuildCacheException("Error while reading cache object from S3 bucket", e); } } else { logger.info("Did not find cache item '{}' in S3 bucket", bucketPath); return false; } }
From source file:cloudExplorer.Get.java
License:Open Source License
public void run() { String message = null;/* w ww . ja v a 2s.c o m*/ AWSCredentials credentials = new BasicAWSCredentials(access_key, secret_key); File file = new File(what); AmazonS3 s3Client = new AmazonS3Client(credentials, new ClientConfiguration().withSignerOverride("S3SignerType")); s3Client.setEndpoint(endpoint); try { long t1 = System.currentTimeMillis(); S3Object s3object = s3Client.getObject(new GetObjectRequest(bucket, what, version)); InputStream objectData = s3object.getObjectContent(); this.writeFile(objectData, destination); long t2 = System.currentTimeMillis(); long diff = t2 - t1; if (!mainFrame.perf) { if (terminal) { System.out.print("\nDownloaded: " + what + " in " + diff / 1000 + " second(s).\n"); } else { mainFrame.jTextArea1.append("\nDownloaded: " + what + " in " + diff / 1000 + " second(s)."); mainFrame.calibrateTextArea(); } } } catch (AmazonServiceException ase) { if (NewJFrame.gui) { mainFrame.jTextArea1.append("\n\nError Message: " + ase.getMessage()); mainFrame.jTextArea1.append("\nHTTP Status Code: " + ase.getStatusCode()); mainFrame.jTextArea1.append("\nAWS Error Code: " + ase.getErrorCode()); mainFrame.jTextArea1.append("\nError Type: " + ase.getErrorType()); mainFrame.jTextArea1.append("\nRequest ID: " + ase.getRequestId()); calibrate(); } else { System.out.print("\n\nError Message: " + ase.getMessage()); System.out.print("\nHTTP Status Code: " + ase.getStatusCode()); System.out.print("\nAWS Error Code: " + ase.getErrorCode()); System.out.print("\nError Type: " + ase.getErrorType()); System.out.print("\nRequest ID: " + ase.getRequestId()); } } catch (Exception get) { } calibrate(); }
From source file:cloudtrailviewer.events.EventLoader.java
License:Open Source License
private void readS3File(String key) throws IOException { AWSCredentials credentials = new BasicAWSCredentials(PropertiesSingleton.getInstance().getProperty("Key"), PropertiesSingleton.getInstance().getProperty("Secret")); AmazonS3 s3Client = new AmazonS3Client(credentials); String bucketName = PropertiesSingleton.getInstance().getProperty("Bucket"); S3Object s3Object = s3Client.getObject(new GetObjectRequest(bucketName, key)); GZIPInputStream gzis = new GZIPInputStream(s3Object.getObjectContent()); BufferedReader bf = new BufferedReader(new InputStreamReader(gzis, "UTF-8")); String outStr = ""; String line;//from w w w.ja va2 s . co m while ((line = bf.readLine()) != null) { outStr += line; } bf.close(); gzis.close(); readLogEvents(outStr); }
From source file:com.adobe.people.jedelson.rugsinlambda.helpers.RugWrapper.java
License:Apache License
public RugWrapper(String requestId) throws IOException { tmpRoot = new File(FileUtils.getTempDirectory().getAbsoluteFile(), requestId); tmpRoot.mkdirs();/* w w w . j av a2 s . c o m*/ repo = new File(tmpRoot, "rugs"); File archiveFolder = new File(repo, groupId + "/" + artifactId + "/" + version); archiveFolder.mkdirs(); archive = new File(archiveFolder, artifactId + "-" + version + ".zip"); AmazonS3Client s3Client = new AmazonS3Client(); S3Object rugFile = s3Client.getObject(rugBucketName, rugObjectKey); FileUtils.copyToFile(rugFile.getObjectContent(), archive); log.info("Saved rug zip in {}", archive); }
From source file:com.aegeus.aws.SimpleStorageService.java
License:Apache License
public InputStream download(String bucket, String key) throws IOException { S3Object object = s3.getObject(bucket, key); return object.getObjectContent(); }
From source file:com.ALC.SC2BOAserver.aws.S3StorageManager.java
License:Open Source License
public InputStream loadInputStream(SC2BOAStorageObject s3Store) throws IOException { S3Object s3 = getS3Object(s3Store); this.lastUpdate = s3.getObjectMetadata().getLastModified(); return s3.getObjectContent(); }
From source file:com.ALC.SC2BOAserver.aws.S3StorageManager.java
License:Open Source License
/** * Loads the raw object data from S3 storage * @param s3Store the s3 object to be loaded from the store * @return input stream for reading in the raw object * @throws IOException/* w w w. jav a2 s.co m*/ */ public InputStream loadStream(SC2BOAStorageObject s3Store) throws IOException { S3Object obj = getS3Object(s3Store); InputStream is = obj.getObjectContent(); return is; }
From source file:com.altoukhov.svsync.fileviews.S3FileSpace.java
License:Apache License
@Override public InputStream readFile(String path) { try {/* ww w .j a v a2s . c o m*/ S3Object s3File = s3.getObject(bucketName, toAbsoluteFilePath(path)); return s3File.getObjectContent(); } catch (AmazonClientException ex) { System.out.println(ex.getMessage()); return null; } }
From source file:com.amazon.aws.samplecode.travellog.aws.S3StorageManager.java
License:Open Source License
public InputStream loadInputStream(TravelLogStorageObject s3Store) throws IOException { S3Object s3 = getS3Object(s3Store); this.lastUpdate = s3.getObjectMetadata().getLastModified(); return s3.getObjectContent(); }
From source file:com.amazon.aws.samplecode.travellog.aws.S3StorageManager.java
License:Open Source License
/** * Loads the raw object data from S3 storage * @param s3Store the s3 object to be loaded from the store * @return input stream for reading in the raw object * @throws IOException/*from w w w . j ava 2s .c om*/ */ public InputStream loadStream(TravelLogStorageObject s3Store) throws IOException { S3Object obj = getS3Object(s3Store); InputStream is = obj.getObjectContent(); return is; }