title: How to download images with specific size from firebase storage
body: <p>I am using firebase storage in my android app to store images uploaded by users. <strong>all images uploaded are square in shape.</strong>
  I discovered that downloading this images consumes a lot of user bandwidth and i would like to reduce this consumption by reducing the size of image downloaded into a <strong>square imageview</strong></p>
  
  <p>I am using Glide to download this images and i have tried to download images of custom size but the image is not appearing on the imageview.</p>
  
  <p><strong>interface</strong></p>
  
  <pre><code>public interface MyDataModel {
    public String buildUrl(int width, int height);
  }
  </code></pre>
  
  <p><strong>my class which extends BaseGlideUrlLoader</strong></p>
  
  <pre><code>public class MyUrlLoader extends BaseGlideUrlLoader&lt;MyDataModel&gt; {
    public MyUrlLoader(Context context) {
      super(context);
    }
  
    @Override
    protected String getUrl(MyDataModel model, int width, int height) {
      // Construct the url for the correct size here.
      return model.buildUrl(width, height);
    }
  }
  </code></pre>
  
  <p><strong>class which implements MyDataModel interface</strong></p>
  
  <pre><code>public class CustomImageSize implements MyDataModel {
  
    private String uri;
  
    public CustomImageSize(String uri){
      this.uri = uri;
    }
  
    @Override
    public String buildUrl(int width, int height) {
  
      return uri + "?w=" + width + "&amp;h=" + height;
    }
  }
  </code></pre>
  
  <p><strong>Finally</strong></p>
  
  <pre><code>CustomImageSize size = new CustomImageSize(uri);
  
    Glide.with(context)
      .using(new MyUrlLoader(context))
      .load(size)
      .centerCrop()
      .priority(Priority.HIGH)
      .into(imageView);
  </code></pre>
  
  <p><strong>RESULTS OF SOLUTION ABOVE</strong></p>
  
  <p>Image is not appearing in my square imageview</p>
  
  <p><strong>SOLUTION 2: use firebase image loader</strong></p>
  
  <pre><code>    // Reference to an image file in Firebase Storage
  StorageReference storageReference = ...;
  
  ImageView imageView = ...;
  
  // Load the image using Glide
  Glide.with(this /* context */)
          .using(new FirebaseImageLoader())
          .load(storageReference)
          .into(imageView);
  </code></pre>
  
  <p><strong>RESULT OF SOLUTION 2 ABOVE</strong></p>
  
  <p><strong>working! image is appearing BUT</strong> it's like entire image is been downloaded which consume a lot of bandwidth. I just want a custom size image e.g 200px by 200px to be downloaded. </p>
  
  <p>How can I do or change in my solution 1 above to download images of custom size from firebase storage?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I have tried to access one of my images <code>https://firebasestorage.googleapis.com/....m.png</code> from the browser and it was loaded successfully to the webpage. but when i try to put to size specific parameters to my image url link <code>https://firebasestorage.googleapis.com/....m.png?w=100&amp;h=100</code> an error appeared on the webpage</p>
  
  <pre><code> {
    "error": {
      "code": 403,
      "message": "Permission denied. Could not perform this operation"
    }
  }
  </code></pre>