code: public static void runExample(
        AdWordsServicesInterface adWordsServices, AdWordsSession session) throws IOException {
      // Get the MediaService.
      MediaServiceInterface mediaService =
          adWordsServices.get(session, MediaServiceInterface.class);
  
      // Create image.
      Image image = new Image();
      image.setData(
          com.google.api.ads.common.lib.utils.Media.getMediaDataFromUrl("https://goo.gl/3b9Wfh"));
      image.setType(MediaMediaType.IMAGE);
  
      Media[] media = new Media[] {image};
  
      // Upload image.
      Media[] result = mediaService.upload(media);
  
      // Display images.
      image = (Image) result[0];
      Map<MediaSize, Dimensions> dimensions = Maps.toMap(image.getDimensions());
      System.out.printf("Image with ID %d, dimensions %dx%d, and MIME type '%s' was "
          + "uploaded.%n", image.getMediaId(), dimensions.get(MediaSize.FULL).getWidth(),
          dimensions.get(MediaSize.FULL).getHeight(), image.getMediaType());
    }
docs: Runs the example.
  
  @param adWordsServices the services factory.
  @param session the session.
  @throws ApiException if the API request failed with one or more service errors.
  @throws RemoteException if the API request failed due to other errors.
  @throws IOException if unable to get media data from the URL.