Description
New Issue Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
- I can reproduce the issue with the latest version of Parse Swift.
- I can reproduce the issue with the latest version of Parse Server.
Issue Description
I am seeing issues when fetching an image. When i fetch an image for the first time, it loads the image corretly. But when it then tries to load for the second time, the image is broken. I looked at what the downloaded image looks like when opening in a text editor.
I noticed it doesn't contain data, but a path. This is an example:
file:\/\/\/var\/folders\/y5\/3qbps9t11cb2fz7lh1x8bw7w0000gn\/T\/com.app.myApp\/CFNetworkDownload_rDopeR.tmp
My uploaded images in the Database are valid images.
I want to point out that this way of fetching images always worked for me. It's since the Beta's that there is something wrong, but I don't find anything on the Apple Developer known issues page.
Steps to reproduce
This is an example of code I use.
let modelQuery = Model.query()
modelQuery.find { result in
switch result {
case .success(let model):
if let imageURL = model.image?.localURL {
print("imageURL: \(imageURL)")
if let imgData = try? Data(contentsOf: imageURL) {
print("imgData: \(imgData)")
print("imgData as string: \(String(decoding: imgData, as: UTF8.self))")
self.imageData = imgData
}
} else {
model.image?.fetch(completion: { result in
switch result {
case .success(let fetchedImage):
if let localImageUrl = fetchedImage.localURL {
print("localImageUrl: \(localImageUrl)")
if let imgData = try? Data(contentsOf: localImageUrl) {
print("imgData: \(imgData)")
print("imgData as string: \(String(decoding: imgData, as: UTF8.self))")
self.imageData = imgData
}
}
case .failure(_):
break
}
})
}
self.model = model
case .failure(_):
break
}
}
This is my log:
Actual Outcome
file:\/\/\/var\/folders\/y5\/3qbps9t11cb2fz7lh1x8bw7w0000gn\/T\/com.app.myApp\/CFNetworkDownload_rDopeR.tmp
Expected Outcome
Image data
Failing Test Case / Pull Request
- 🤩 I submitted a PR with a fix and a test case.
- 🧐 I submitted a PR with a failing test case.
Environment
Parse Swift
- SDK version:
1.9.8
- Operating system (iOS, macOS, watchOS, etc.):
iOS, macOS
- Operating system version:
iOS 15 Beta 8, Monterey 12.0 Beta 6
Server
- Parse Server version:
4.4.0
- Operating system:
Back4App
Logs
localImageUrl: file:///Users/name/Library/Containers/com.app.myApp/Data/Library/Application%20Support/parse/com.app.myApp/Downloads/d48e0511e7660ab8e59fa2bb74cd48a4_1600.png
imgData: 123 bytes
imgData as string: "file:\/\/\/var\/folders\/y5\/3qbps9t11cb2fz7lh1x8bw7w0000gn\/T\/com.app.myApp\/CFNetworkDownload_rDopeR.tmp"