ImageUploadData
public struct ImageUploadData : Content
Used to upload an image file or refer to an already-uploaded image. Either filename
or image
should always be set.
If both are set, filename
is ignored and image
is processed and saved with a new name. A more Swift-y way to do this
would be an Enum with associated values, except Codable support becomes a pain and makes it difficult to understand
what the equivalent JSON struct will look like.
Required by: POST /api/v3/user/image
Incorporated into PostContentData
, which is in turn required by several routes.
See UserController.imageHandler(_:data)
.
-
The filename of an existing image previously uploaded to the server. Ignored if image is set.
Declaration
Swift
var filename: String?
-
The image in
Data
format.Declaration
Swift
var image: Data?
-
Failable initializer; either filename or image must be non-nil and non-empty.
Declaration
Swift
init?(_ filename: String?, _ image: Data?)