Classes that I use as templates for Server Side Swift using Vapor.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Vapor Autocomplete | |
_vapor_completion() { | |
COMPREPLY=() | |
local cur="${COMP_WORDS[COMP_CWORD]}" | |
local prev="${COMP_WORDS[COMP_CWORD-1]}" | |
local vaporCommands=$(vapor --help | grep 'Usage:' | sed -E 's/^[^<]*<([^>]*)>/\1/' | tr '|' '\n' 2>/dev/null) | |
local genCommands="generate migration controller model resource" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
drop.post("upload") { request in | |
print(request.multipart?["image"]?.file?.data) | |
guard let fileData = request.multipart?["image"]?.file?.data else { | |
throw Abort.custom(status: .badRequest, message: "No file in request") | |
} | |
let workPath = drop.workDir | |
let name = UUID().uuidString + ".png" |