return false;
}
@Override
protected void run() throws Exception {
final AmazonS3 s3 = new AmazonS3(properties());
if ("get".equals(op)) { //$NON-NLS-1$
final URLConnection c = s3.get(bucket, key);
int len = c.getContentLength();
final InputStream in = c.getInputStream();
try {
outw.flush();
final byte[] tmp = new byte[2048];
while (len > 0) {
final int n = in.read(tmp);
if (n < 0)
throw new EOFException(MessageFormat.format(
CLIText.get().expectedNumberOfbytes,
valueOf(len)));
outs.write(tmp, 0, n);
len -= n;
}
outs.flush();
} finally {
in.close();
}
} else if ("ls".equals(op) || "list".equals(op)) { //$NON-NLS-1$//$NON-NLS-2$
for (final String k : s3.list(bucket, key))
outw.println(k);
} else if ("rm".equals(op) || "delete".equals(op)) { //$NON-NLS-1$ //$NON-NLS-2$
s3.delete(bucket, key);
} else if ("put".equals(op)) { //$NON-NLS-1$
final OutputStream os = s3.beginPut(bucket, key, null, null);
final byte[] tmp = new byte[2048];
int n;
while ((n = System.in.read(tmp)) > 0)
os.write(tmp, 0, n);
os.close();