List of usage examples for com.amazonaws.services.s3.model S3Object getObjectContent
public S3ObjectInputStream getObjectContent()
From source file:org.huahinframework.core.util.S3Utils.java
License:Apache License
/** * {@inheritDoc}// w w w . j av a 2s . c o m */ @Override public Map<String, String[]> getSimpleMaster(String[] masterLabels, int joinColumnNo, String path, String separator) throws IOException, URISyntaxException { Map<String, String[]> m = new HashMap<String, String[]>(); URI uri = new URI(path); String key = uri.getPath().substring(1); S3Object s3Object = s3.getObject(uri.getHost(), key); BufferedReader br = new BufferedReader(new InputStreamReader(s3Object.getObjectContent(), "UTF-8")); String line; while ((line = br.readLine()) != null) { String[] strings = StringUtil.split(line, separator, false); if (masterLabels.length != strings.length) { continue; } String joinData = strings[joinColumnNo]; String[] data = new String[strings.length]; for (int i = 0; i < strings.length; i++) { data[i] = strings[i]; } m.put(joinData, data); } br.close(); return m; }
From source file:org.huahinframework.core.util.S3Utils.java
License:Apache License
/** * {@inheritDoc}// w ww . ja v a 2 s . co m */ @Override public Map<List<String>, String[]> getSimpleColumnsMaster(String[] masterLabels, int[] joinColumnNo, String path, String separator) throws IOException, URISyntaxException { Map<List<String>, String[]> m = new HashMap<List<String>, String[]>(); URI uri = new URI(path); String key = uri.getPath().substring(1); S3Object s3Object = s3.getObject(uri.getHost(), key); BufferedReader br = new BufferedReader(new InputStreamReader(s3Object.getObjectContent(), "UTF-8")); String line; while ((line = br.readLine()) != null) { String[] strings = StringUtil.split(line, separator, false); if (masterLabels.length != strings.length) { continue; } List<String> joinData = new ArrayList<String>(); for (int i : joinColumnNo) { joinData.add(strings[i]); } String[] data = new String[strings.length]; for (int i = 0; i < strings.length; i++) { data[i] = strings[i]; } m.put(joinData, data); } br.close(); return m; }
From source file:org.icgc.dcc.storage.server.repository.s3.S3DownloadService.java
License:Open Source License
private ObjectSpecification readSpecification(S3Object obj) throws JsonParseException, JsonMappingException, IOException { @Cleanup//from w w w . j ava 2s .co m val inputStream = obj.getObjectContent(); return MAPPER.readValue(inputStream, ObjectSpecification.class); }
From source file:org.kuali.maven.wagon.S3Wagon.java
License:Educational Community License
/** * Pull an object out of an S3 bucket and write it to a file *//* w w w . j a v a 2s . com*/ @Override protected void getResource(final String resourceName, final File destination, final TransferProgress progress) throws ResourceDoesNotExistException, IOException { // Obtain the object from S3 S3Object object = null; try { String key = basedir + resourceName; object = client.getObject(bucket.getName(), key); } catch (Exception e) { throw new ResourceDoesNotExistException( "Resource " + resourceName + " does not exist in the repository", e); } // InputStream in = null; OutputStream out = null; try { in = object.getObjectContent(); out = new TransferProgressFileOutputStream(destination, progress); byte[] buffer = new byte[1024]; int length; while ((length = in.read(buffer)) != -1) { out.write(buffer, 0, length); } } finally { IOUtils.closeQuietly(in); IOUtils.closeQuietly(out); } }
From source file:org.mule.module.s3.simpleapi.SimpleAmazonS3AmazonDevKitImpl.java
License:Open Source License
public S3ObjectInputStream getObjectContent(@NotNull S3ObjectId objectId, @NotNull ConditionalConstraints conditionalConstraints) { Validate.notNull(objectId);//from w w w .j a v a2 s. c om S3Object object = getObject(objectId, conditionalConstraints); if (object == null) { return null; } return object.getObjectContent(); }
From source file:org.nickelproject.util.streamUtil.S3InputStreamFactory.java
License:Apache License
@Override public InputStream getInputStream() { final S3Object object = s3Client.getObject(new GetObjectRequest(bucketName, key)); return object.getObjectContent(); }
From source file:org.nuxeo.liveconnect.importer.aws.LiveconnectS3Blobprovider.java
License:Apache License
@Override public InputStream getStream(ManagedBlob blob) throws IOException { LiveConnectFileInfo fileInfo = toFileInfo(blob); GetObjectRequest request = new GetObjectRequest(bucketName, fileInfo.getFileId()); S3Object object = amazonS3.getObject(request); return object.getObjectContent(); }
From source file:org.onebusaway.admin.service.impl.S3FileServiceImpl.java
License:Apache License
@Override /**//from w w w. j a v a 2 s. co m * Retrieve the specified key from S3 and store in the given directory. */ public String get(String key, String tmpDir) { _log.debug("get(" + key + ", " + tmpDir + ")"); NYCFileUtils fs = new NYCFileUtils(); String filename = fs.parseFileName(key); _log.debug("filename=" + filename); GetObjectRequest request = new GetObjectRequest(this._bucketName, key); S3Object file = _s3.getObject(request); String pathAndFileName = tmpDir + File.separator + filename; fs.copy(file.getObjectContent(), pathAndFileName); return pathAndFileName; }
From source file:org.onebusaway.admin.service.impl.S3FileServiceImpl.java
License:Apache License
public InputStream get(String key) { GetObjectRequest request = new GetObjectRequest(this._bucketName, key); S3Object file = _s3.getObject(request); return file.getObjectContent(); }
From source file:org.opencb.opencga.core.data.source.S3Source.java
License:Apache License
public InputStream getInputStream(String path) { String ak = "AKIAI3BZQ2VG6GPWQBVA"; String sk = "oDDIv+OAQeQVj9sy1CcWeeJsOMAhbh9KIpJ7hiDK"; String bucket = "nacho-s3"; AWSCredentials myCredentials = new BasicAWSCredentials(ak, sk); AmazonS3Client s3Client = new AmazonS3Client(myCredentials); S3Object object = s3Client.getObject(new GetObjectRequest(bucket, path)); return object.getObjectContent(); }