Removing the requirement for appcues_attachment_type.
URLSession.downloadTask(with:completionHandler:) is almost as easy as Data(contentsOf:). It creates a download task that saves the results to a file which we can copy to our attachment with the mime type of the URLResponse. Using UTType means we don't need a hardcoded map of mime types to file extensions (even if the pre-ios 14 fallback is a bit ugly).
Removing the requirement for
appcues_attachment_type
.URLSession.downloadTask(with:completionHandler:)
is almost as easy asData(contentsOf:)
. It creates a download task that saves the results to a file which we can copy to our attachment with the mime type of theURLResponse
. UsingUTType
means we don't need a hardcoded map of mime types to file extensions (even if the pre-ios 14 fallback is a bit ugly).