本文整理了Java中ch.cyberduck.core.Local.getInputStream()
方法的一些代码示例,展示了Local.getInputStream()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Local.getInputStream()
方法的具体详情如下:
包路径:ch.cyberduck.core.Local
类名称:Local
方法名:getInputStream
暂无
代码示例来源:origin: iterate-ch/cyberduck
public InputStream getInputStream() throws AccessDeniedException {
return this.getInputStream(path);
}
代码示例来源:origin: iterate-ch/cyberduck
private NSDictionary read(final Local file) {
try {
return (NSDictionary) XMLPropertyListParser.parse(file.getInputStream());
}
catch(ParserConfigurationException
| IOException
| SAXException
| PropertyListFormatException
| ParseException
| AccessDeniedException e) {
log.warn(String.format("Failure %s reading dictionary from %s", e.getMessage(), file));
}
return null;
}
代码示例来源:origin: iterate-ch/cyberduck
protected void read(final ProtocolFactory protocols, final Local child) throws AccessDeniedException {
try {
final BufferedReader in = new BufferedReader(new InputStreamReader(child.getInputStream(),
Charset.forName("UTF-8")));
AbstractHandler handler = this.getHandler(protocols);
final XMLReader xr = XMLReaderFactory.createXMLReader();
xr.setContentHandler(handler);
xr.setErrorHandler(handler);
xr.parse(new InputSource(in));
}
catch(SAXException | IOException e) {
log.error(String.format("Error reading %s:%s", this.getFile(), e.getMessage()));
}
}
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public InputStream getInputStream() throws AccessDeniedException {
final NSURL resolved;
try {
resolved = this.lock(false);
if(null == resolved) {
return super.getInputStream();
}
}
catch(AccessDeniedException e) {
log.warn(String.format("Failure obtaining lock for %s. %s", this, e.getMessage()));
return super.getInputStream();
}
final InputStream proxy = super.getInputStream(resolved.path());
return new LockReleaseProxyInputStream(proxy, resolved);
}
代码示例来源:origin: iterate-ch/cyberduck
/**
* Read invalid JSON format.
*/
protected void read(final ProtocolFactory protocols, final Local file) throws AccessDeniedException {
try {
BufferedReader in = new BufferedReader(new InputStreamReader(file.getInputStream(), Charset.forName("UTF-8")));
try {
String l;
while((l = in.readLine()) != null) {
Matcher array = Pattern.compile("\\[(.*?)\\]").matcher(l);
while(array.find()) {
Matcher entries = Pattern.compile("\\{(.*?)\\}").matcher(array.group(1));
while(entries.find()) {
final String entry = entries.group(1);
this.read(protocols, entry);
}
}
}
}
finally {
IOUtils.closeQuietly(in);
}
}
catch(IOException e) {
throw new AccessDeniedException(e.getMessage(), e);
}
}
代码示例来源:origin: iterate-ch/cyberduck
public Map<String, Host> refresh() {
final long mtime = configuration.attributes().getModificationDate();
if(mtime != lastModified) {
try {
final InputStream in = configuration.getInputStream();
try {
hosts = this.parse(in);
}
finally {
IOUtils.closeQuietly(in);
}
}
catch(AccessDeniedException | IOException none) {
log.warn(String.format("Failure reading %s", configuration));
hosts = Collections.emptyMap();
}
lastModified = mtime;
}
return hosts;
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public void cleanup(final Transfer download) {
// Save checksum before edit
try {
checksum = ChecksumComputeFactory.get(HashAlgorithm.md5).compute(local.getInputStream(), new TransferStatus());
}
catch(BackgroundException e) {
log.warn(String.format("Error computing checksum for %s. %s", local, e.getDetail()));
}
}
};
代码示例来源:origin: iterate-ch/cyberduck
public OpenSSHHostKeyVerifier(final Local file) {
this.file = file;
InputStream in = null;
try {
if(!file.exists()) {
LocalTouchFactory.get().touch(file);
}
in = file.getInputStream();
database = new DelegatingOpenSSHKnownHosts(file);
}
catch(IOException | SSHRuntimeException e) {
log.error(String.format("Cannot read known hosts file %s", file), e);
}
catch(AccessDeniedException e) {
log.warn(String.format("Failure reading %s", file));
}
finally {
IOUtils.closeQuietly(in);
}
}
代码示例来源:origin: iterate-ch/cyberduck
private KeyFormat detectKeyFormat(final Local identity) throws BackgroundException {
final KeyFormat format;
try (InputStream is = identity.getInputStream()) {
format = KeyProviderUtil.detectKeyFileFormat(
new InputStreamReader(is, StandardCharsets.UTF_8),
true);
}
catch(IOException e) {
throw new DefaultIOExceptionMappingService().map(e);
}
return format;
}
}
代码示例来源:origin: iterate-ch/cyberduck
public void copy(final Local copy, final CopyOptions options) throws AccessDeniedException {
if(copy.equals(this)) {
log.warn(String.format("%s and %s are identical. Not copied.", this.getName(), copy.getName()));
}
else {
if(log.isDebugEnabled()) {
log.debug(String.format("Copy to %s with options %s", copy, options));
}
InputStream in = null;
OutputStream out = null;
try {
in = this.getInputStream();
out = copy.getOutputStream(options.append);
IOUtils.copy(in, out);
}
catch(IOException e) {
throw new LocalAccessDeniedException(MessageFormat.format(
LocaleFactory.localizedString("Cannot copy {0}", "Error"), this.getName()), e);
}
finally {
IOUtils.closeQuietly(in);
IOUtils.closeQuietly(out);
}
}
}
代码示例来源:origin: iterate-ch/cyberduck
private Properties load() {
final Properties properties = new Properties();
try {
new DefaultLocalDirectoryFeature().mkdir(file.getParent());
}
catch(AccessDeniedException e) {
log.warn(String.format("Failure saving credentials to %s. %s", file.getAbsolute(), e.getDetail()));
}
if(file.exists()) {
try {
try (InputStream in = file.getInputStream()) {
properties.load(in);
}
}
catch(AccessDeniedException e) {
log.warn(String.format("Failure reading credentials from %s. %s", file.getAbsolute(), e.getDetail()));
}
catch(IOException e) {
log.warn(String.format("Failure reading credentials from %s. %s", file.getAbsolute(), e.getMessage()));
}
}
return properties;
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public Collection<S> readCollection(final Local file) throws AccessDeniedException {
final Collection<S> c = new Collection<S>();
final NSArray list = (NSArray) this.parse(file.getInputStream());
if(null == list) {
log.error(String.format("Invalid bookmark file %s", file));
return c;
}
for(int i = 0; i < list.count(); i++) {
NSObject next = list.objectAtIndex(i);
if(next instanceof NSDictionary) {
final NSDictionary dict = (NSDictionary) next;
final S object = this.deserialize(dict);
if(null == object) {
continue;
}
c.add(object);
}
}
return c;
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public StorageObject upload(final Path file, final Local local, final BandwidthThrottle throttle,
final StreamListener listener, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
if(Checksum.NONE == status.getChecksum()) {
// The client-side checksum is passed to the BlackPearl gateway by supplying the applicable CRC HTTP header.
// If this is done, the BlackPearl gateway verifies that the data received matches the checksum provided.
// End-to-end data protection requires that the client provide the CRC when uploading the object and then
// verify the CRC after downloading the object at a later time (see Get Object). The BlackPearl gateway also
// verifies the CRC when reading from physical data stores so the gateway can identify problems before
// transmitting data to the client.
status.setChecksum(writer.checksum(file).compute(local.getInputStream(), status));
}
// Make sure file is available in cache
final List<TransferStatus> chunks = bulk.query(Transfer.Type.upload, file, status);
StorageObject stored = null;
for(TransferStatus chunk : chunks) {
chunk.setChecksum(ChecksumComputeFactory.get(HashAlgorithm.md5).compute(local.getInputStream(), chunk));
stored = super.upload(file, local, throttle, listener, chunk, callback);
}
return stored;
}
代码示例来源:origin: iterate-ch/cyberduck
if(Checksum.NONE != attributes.getChecksum()) {
final ChecksumCompute compute = ChecksumComputeFactory.get(attributes.getChecksum().algorithm);
if(compute.compute(local.getInputStream(), parent).equals(attributes.getChecksum())) {
if(log.isInfoEnabled()) {
log.info(String.format("Skip file %s with checksum %s", file, local.attributes().getChecksum()));
代码示例来源:origin: iterate-ch/cyberduck
/**
* @param file A valid bookmark dictionary
* @return Null if the file cannot be deserialized
* @throws AccessDeniedException If the file is not readable
*/
@Override
public S read(final Local file) throws AccessDeniedException {
if(!file.exists()) {
throw new LocalAccessDeniedException(file.getAbsolute());
}
if(!file.isFile()) {
throw new LocalAccessDeniedException(file.getAbsolute());
}
final S deserialized = this.read(file.getInputStream());
if(null == deserialized) {
throw new AccessDeniedException(String.format("Failure parsing file %s", file.getName()));
}
return deserialized;
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public Reply upload(final Path file, final Local local, final BandwidthThrottle throttle,
final StreamListener listener, final TransferStatus status,
final ConnectionCallback callback) throws BackgroundException {
final InputStream in = local.getInputStream();
final StatusOutputStream<Reply> out = writer.write(file, status, callback);
new StreamCopier(status, status)
.withOffset(status.getOffset())
.withLimit(status.getLength())
.withListener(listener)
.transfer(in, new ThrottledOutputStream(out, throttle));
return out.getStatus();
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public StorageObject upload(final Path file, final Local local, final BandwidthThrottle throttle,
final StreamListener listener, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
final S3Protocol.AuthenticationHeaderSignatureVersion signatureVersion = session.getSignatureVersion();
switch(signatureVersion) {
case AWS4HMACSHA256:
if(Checksum.NONE == status.getChecksum()) {
status.setChecksum(writer.checksum(file).compute(local.getInputStream(), status));
}
break;
}
try {
return super.upload(file, local, throttle, listener, status, callback);
}
catch(InteroperabilityException e) {
if(!session.getSignatureVersion().equals(signatureVersion)) {
// Retry if upload fails with Header "x-amz-content-sha256" set to the hex-encoded SHA256 hash of the
// request payload is required for AWS Version 4 request signing
return this.upload(file, local, throttle, listener, status, callback);
}
throw e;
}
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public StorageObject call() throws BackgroundException {
if(overall.isCanceled()) {
throw new ConnectionCanceledException();
}
final TransferStatus status = new TransferStatus()
.length(length)
.skip(offset);
status.setHeader(overall.getHeader());
status.setNonces(overall.getNonces());
status.setChecksum(writer.checksum(segment).compute(local.getInputStream(), status));
status.setSegment(true);
return SwiftLargeObjectUploadFeature.super.upload(
segment, local, throttle, listener, status, overall, new StreamProgress() {
@Override
public void progress(final long bytes) {
status.progress(bytes);
// Discard sent bytes in overall progress if there is an error reply for segment.
overall.progress(bytes);
}
@Override
public void setComplete() {
status.setComplete();
}
}, callback);
}
}, overall));
代码示例来源:origin: iterate-ch/cyberduck
@Override
public B2UploadPartResponse call() throws BackgroundException {
if(overall.isCanceled()) {
throw new ConnectionCanceledException();
}
final TransferStatus status = new TransferStatus()
.length(length)
.skip(offset);
status.setHeader(overall.getHeader());
status.setNonces(overall.getNonces());
status.setChecksum(writer.checksum(file).compute(local.getInputStream(), status));
status.setSegment(true);
status.setPart(partNumber);
return (B2UploadPartResponse) B2LargeUploadService.super.upload(file, local, throttle, listener, status, overall, new StreamProgress() {
@Override
public void progress(final long bytes) {
status.progress(bytes);
// Discard sent bytes in overall progress if there is an error reply for segment.
overall.progress(bytes);
}
@Override
public void setComplete() {
status.setComplete();
}
}, callback);
}
}, overall));
代码示例来源:origin: iterate-ch/cyberduck
public Reply upload(final Path file, final Local local, final BandwidthThrottle throttle,
final StreamListener listener, final TransferStatus status,
final StreamCancelation cancel, final StreamProgress progress, final ConnectionCallback callback) throws BackgroundException {
try {
final Digest digest = this.digest();
// Wrap with digest stream if available
final InputStream in = this.decorate(local.getInputStream(), digest);
final StatusOutputStream<Reply> out = writer.write(file, status, callback);
new StreamCopier(cancel, progress)
.withOffset(status.getOffset())
.withLimit(status.getLength())
.withListener(listener)
.transfer(in, new ThrottledOutputStream(out, throttle));
final Reply response = out.getStatus();
this.post(file, digest, response);
return response;
}
catch(HttpResponseException e) {
throw new HttpResponseExceptionMappingService().map("Upload {0} failed", e, file);
}
catch(IOException e) {
throw new HttpExceptionMappingService().map("Upload {0} failed", e, file);
}
}
内容来源于网络,如有侵权,请联系作者删除!