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

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -