title: Download image using url and save to internal storage
body: <p>I have tried different methods. But still I am not able to save the image to the specified location. I don't know what's the problem. need some suggestions. The path is not created and the image in not saved.</p>
  
  <pre><code>class DownloadAndSaveImage(context: Context) : AsyncTask&lt;String, Unit, Unit&gt;() {
  
  
      private var mContext: WeakReference&lt;Context&gt; = WeakReference(context)
      override fun doInBackground(vararg params: String?) {
          val url = params[0]
          val requestOptions = RequestOptions().override(100)
              .downsample(DownsampleStrategy.CENTER_INSIDE)
              .skipMemoryCache(true)
              .diskCacheStrategy(DiskCacheStrategy.NONE)
  
          mContext.get()?.let {
              val bitmap = Glide.with(it)
                  .asBitmap()
                  .load(url)
                  .apply(requestOptions)
                  .submit()
                  .get()
  
              try {
                  val path = File(Environment.DIRECTORY_DCIM)
                  val dir =path.absolutePath
                  val file=File(dir+"/EAcademy","schoolImage.jpg")
                  if (!file.exists()) {
                      file.mkdir()
                  }
                  val out = FileOutputStream(file)
                  bitmap.compress(Bitmap.CompressFormat.JPEG, 85, out)
                  out.flush()
                  out.close()
                  Log.i("Tribhuwan", "Saved Image")
              } catch (e: Exception) {
                  Log.i("Tribhuwan", "Failed to save")
              }
          }
      }
  
  
  }
  </code></pre>