title: Java Google Cloud Storage upload media link null, but image uploads
body: <p>I'm trying to upload an image to a existing bucket in my Google Cloud Storage.
  The image file gets uploaded successfully when I go and check, <br> but the returned download url is <code>null</code></p>
  
  <h1>CODE</h1>
  
  <pre><code>private String uploadImage(File filePath, String blobName, File uploadCreds) throws FileNotFoundException, IOException{
  
  
     Storage storage = StorageOptions.newBuilder().setProjectId("myProjectId")
                  .setCredentials(ServiceAccountCredentials.fromStream(new FileInputStream(uploadCreds)))
                  .build()
                  .getService();
  
                      String bucketName = "myBucketName"; 
                      Bucket bucket = storage.get(bucketName);
          BlobId blobId = BlobId.of(bucket.getName(), blobName);
          InputStream inputStream = new FileInputStream(filePath);
          BlobInfo blobInfo = BlobInfo.newBuilder(blobId).setContentType("image/jpeg").build();
  
  
      try (WriteChannel writer = storage.writer(blobInfo)) {
          byte[] buffer = new byte[1024];
          int limit;
          try {
              while ((limit = inputStream.read(buffer)) &gt;= 0) {
                  writer.write(ByteBuffer.wrap(buffer, 0, limit));
              }
  
          } catch (Exception ex) {
              ex.printStackTrace();
          }finally {
              writer.close();
  
          }
                       System.out.println("Image URL : " + blobInfo.getMediaLink());
                       System.out.println("Blob URL : " + blobInfo.getSelfLink());
                       return blobInfo.getMediaLink();
      }
  
  
  }
  </code></pre>
  
  <p>filePath is the Image File <br>
  blobName is a random Image Name <br>
  uploadCreds is my credintials.json file <br></p>
  
  <p>Why is the <code>blobInfo.getMediaLink()</code> and <code>blobInfo.getSelfLink()</code> returning <code>null</code>? <br> What am i doing wrong?</p>