swift - file upload using Vapor -
i can't find example of handling file upload, how save specific folder.
here code, addvideo http post multipart/form-data:
videos.post("addvideo") { req in // need save req.multipart["video"] /data/videos/ return try json(node: ["status": 0, "message": "success"]) }
from multipart.file
bytes
, convert data
.
guard let file = request.multipart?["video"]?.file else { return "not found" } try data(file.data).write(to: url(fileurlwithpath: "/data/videos/filename"))
you can filename file
object or make own.
Comments
Post a Comment