code: func (r *run) urlFileRef(urlstr, filename string) string {
  	im := r.im
  	im.mu.Lock()
  	if br, ok := im.imageFileRef[urlstr]; ok {
  		im.mu.Unlock()
  		return br.String()
  	}
  	im.mu.Unlock()
  
  	if urlstr == "" {
  		return ""
  	}
  	res, err := ctxutil.Client(r.Context()).Get(urlstr)
  	if err != nil {
  		log.Printf("swarm: couldn't fetch image %q: %v", urlstr, err)
  		return ""
  	}
  	defer res.Body.Close()
  
  	fileRef, err := schema.WriteFileFromReader(r.Context(), r.Host.Target(), filename, res.Body)
  	if err != nil {
  		r.errorf("couldn't write file: %v", err)
  		return ""
  	}
  
  	im.mu.Lock()
  	defer im.mu.Unlock()
  	im.imageFileRef[urlstr] = fileRef
  	return fileRef.String()
  }
docs: // urlFileRef slurps urlstr from the net, writes to a file and returns its
  // fileref or "" on error or if urlstr was empty.