I believe this is because the decoder expects the file to be nested, since that’s what the body will look like. So it should work with
struct MyType: Decodable {
let file: File // note that the name here much match the key of the file here, in your case `file` because its `file=@...`, if you had `image=@...` then they property name would be `image`
}
struct MyType: Decodable {
let file: File
var name: String {
return file.filename
}
var data: ByteBuffer {
return file.data
}
}
Otherwise in the route you have to use file.file.filname to refer to the filename. Here only file.name and file.data is necessary.
Now I am facing an issue with curl: instead of picking the file in the current directory, I don't know for what reason it is looking it in the Library/Developer/Xcode/DerivedData/Build/Products/Debug/Public folder !
I'd recommend you to inspect the built app: the hierarchy in Xcode might not (and most likely will not) reflect the hierarchy in the built app, I seen cases when the latter was a flattened out version.
Also, could you not use Bundle.main.url(forResource:, withExtension:) ?
@tera could you be more specific what you mean by "inspecting the built app" ?
Regarding Bundle.main.url(forResource:, withExtension:) I am not sure how you want to use it : I believe fileio.writeFile() expects a String path not an url. And in this case it is of a folder not of a resource.
@tera sorry I have no idea where to find the mentionned "report navigator tab."
Regarding the path of the file, I don't think it is the issue since I checked in Debug mode and as mentionned before the path as a String looks correct:
I might have misread the question though. I assumed you have a fixed set of fixed resources you are shipping with your app that you'd like to upload, and the only way to change those files is via rebuilding the app.
Well, good news : I tried it again this morning and now it seems to work fine. My png file was finally uploaded into the Public/Uploads folder as expected.
(The only bad news is I have no idea what was wrong las week)