Package org.eclipse.jgit.transport

Examples of org.eclipse.jgit.transport.AmazonS3


    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();
View Full Code Here


    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 = ins.read(tmp)) > 0)
        os.write(tmp, 0, n);
      os.close();
View Full Code Here

    return false;
  }

  @Override
  protected void run() throws Exception {
    final AmazonS3 s3 = new AmazonS3(properties());

    if ("get".equals(op)) {
      final URLConnection c = s3.get(bucket, key);
      int len = c.getContentLength();
      final InputStream in = c.getInputStream();
      try {
        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, len));
          System.out.write(tmp, 0, n);
          len -= n;
        }
      } finally {
        in.close();
      }

    } else if ("ls".equals(op) || "list".equals(op)) {
      for (final String k : s3.list(bucket, key))
        System.out.println(k);

    } else if ("rm".equals(op) || "delete".equals(op)) {
      s3.delete(bucket, key);

    } else if ("put".equals(op)) {
      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();
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.transport.AmazonS3

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.