AlamofireImage icon indicating copy to clipboard operation
AlamofireImage copied to clipboard

Response Content-Type "text/plain" does not match any acceptable types

Open nick70007 opened this issue 2 years ago • 0 comments

In mY swiftUI App i am trying to download image with POST request abd that post request contains "text/plain" type as output and i am getting this error:

Couldn't downloaded image: Response Content-Type "text/plain" does not match any acceptable types: image/jp2,image/bmp,application/octet-stream,image/x-icon,image/heic,image/x-bmp,image/heif,image/x-xbitmap,image/webp,image/x-win-bitmap,image/jpg,image/gif,image/png,image/ico,image/jpeg,image/tiff,image/x-ms-bmp.

The url i am trying to download:- https://ipfs.infura.io:5001/api/v0/block/cat?arg=QmcrJRMrFnGGHtC4bwkDYsnqaG9fmGSV6qHATa9h6j3jxi

My code Snippet:

      AF.request(urlString, method: .post).responseImage { response in
          debugPrint(response)
          debugPrint(response.result)

        if case .success(let downloadedImage) = response.result {
            print("Image downloaded: \(downloadedImage)")

            DispatchQueue.main.async {
                self.imageCache.set(forKey: self.urlString!, image: downloadedImage)
                self.image = downloadedImage
            }
        } else if case .failure(let error) = response.result {
            print("Couldn't downloaded image: \(error.localizedDescription)")
        }
    }

nick70007 avatar Mar 07 '22 05:03 nick70007