title: Save Image in Google Cloud Storage
body: <p>I'm currently working on a project where we should have the possibility to upload files to the Google Cloud Storage. So we created an Bucket and I added the Maven dependency to my local "normal" application:</p>
  
  <pre><code>&lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.google.appengine.tools&lt;/groupId&gt;
          &lt;artifactId&gt;appengine-gcs-client&lt;/artifactId&gt;
          &lt;version&gt;RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  </code></pre>
  
  <p>Then I started to read a local file and tried to push that to the Google Cloud Storage in a simply main:</p>
  
  <pre><code>try {
      final GcsService gcsService = GcsServiceFactory
          .createGcsService();
  
      File file = new File("/tmp/test.jpg");
      FileInputStream fis = new FileInputStream(file);
      GcsFilename fileName = new GcsFilename("test1213","test.jpg");
      GcsOutputChannel outputChannel;
      outputChannel = gcsService.createOrReplace(fileName, GcsFileOptions.getDefaultInstance());
      copy(fis, Channels.newOutputStream(outputChannel));
  } catch (IOException e) {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>My <code>copy</code> method looks like this:</p>
  
  <pre><code>private static final int BUFFER_SIZE = 2 * 1024 * 1024;
  
  private static void copy(InputStream input, OutputStream output)
          throws IOException {
      try {
          byte[] buffer = new byte[BUFFER_SIZE];
          int bytesRead = input.read(buffer);
          while (bytesRead != -1) {
              output.write(buffer, 0, bytesRead);
              bytesRead = input.read(buffer);
          }
      } finally {
          input.close();
          output.close();
      }
  }
  </code></pre>
  
  <p>All I get from that is this:</p>
  
  <pre><code>The API package 'file' or call 'Create()' was not found.
  </code></pre>
  
  <p>After searching a lot in google, reading documentations even searching in bing i found this entry: <a href="https://stackoverflow.com/questions/13813668/the-api-package-channel-or-call-createchannel-was-not-found">The API package &#39;channel&#39; or call &#39;CreateChannel()&#39; was not found</a></p>
  
  <p>It says that there is no way to use the <code>appengine.tools -&gt; gcs-client</code> without such an AppEngine App. But is there an easy way to upload files to the Google Cloud Storage without to be forced on using the AppEngine service?</p>