vapor

Image Upload in Vapor 3 using PostgreSQL

心已入冬 提交于 2020-01-12 14:20:30
问题 I'm following this guys Martin Lasek Tutorials and now i'm at "image upload". It seems that no one has the answer to the question "How do you upload images i Vapor 3" Db connection is ok, all the other values are saved. This is mye create method: func create(_ req: Request) throws -> Future<Response> { return try req.content.decode(Question.self).flatMap { question in return question.save(on: req).map { _ in return req.redirect(to: "/form") } } } and Model: final class Question:

Image Upload in Vapor 3 using PostgreSQL

蓝咒 提交于 2020-01-12 14:20:27
问题 I'm following this guys Martin Lasek Tutorials and now i'm at "image upload". It seems that no one has the answer to the question "How do you upload images i Vapor 3" Db connection is ok, all the other values are saved. This is mye create method: func create(_ req: Request) throws -> Future<Response> { return try req.content.decode(Question.self).flatMap { question in return question.save(on: req).map { _ in return req.redirect(to: "/form") } } } and Model: final class Question:

How to use multi-path update with the REST API in Firebase? Error 400

拟墨画扇 提交于 2020-01-09 08:11:28
问题 I would like to update multiple nodes in a single operation using the firebase REST API and Vapor framework. When I make .patch request to Firebase I get error from Vapor client: The operation couldn’t be completed. Error 400 Bad Request Could anyone tell me if finalDictionary is initialized correctly before being converted in JSON? Desired output for Users node: brv-61e24 Users usersUID customer bookingNumber timeStampBookingCancelled CleanersUID:"cleanersUID" TimeStampBookingClaimed:

Vapor: route return before all modification done

妖精的绣舞 提交于 2020-01-06 07:39:09
问题 I have following route: router.post([Page].self, at: "/fetchStatusOfManagedReleases") { (req, pages) -> Future<[Page]> in let eventIds = pages.map { $0.events }.flatMap { $0 }.map { $0.id } return Release.query(on: req).filter(\.fbId ~~ eventIds).all().map { releases in var result: [Page] = [] for p in pages { let page = p var pageEvents: [Event] = [] for e in p.events { let event = e if let release = releases.first(where: { $0.fbId == e.id }) { event.inProgress = release.inProgress event

Gitlab - Google compute engine Continuous delivery

走远了吗. 提交于 2020-01-04 02:08:22
问题 What I am trying to do is to enable Continuous delivery from GitLab to my compute engine on Google Cloude. I have Ubuntu 16.04 TSL running over there. I did install all components needed to run my project like: Swift, vapor, nginx. I have manage to install Gitlab runner as well and created a runner whcihc is accessible from my gitlab repo. Everytime I do push on master the runner triggers. What happen is a failure due to: could not create leading directories of '/home/gitlab-runner/builds

Deploying Vapor with heroku

允我心安 提交于 2020-01-03 02:49:29
问题 I have created a very simple app with one route in main.swift . It reads a city from a query string and use it to get the weather (through the yahoo API) of that city. this is the route: drop.get("whether") { request in guard let city = request.data["city"]?.string else { return try JSON(node: ["Error": "no city given"]) } return try drop.client.get("https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)

Vapor 3 - send a HTTPRequest

喜夏-厌秋 提交于 2020-01-02 02:41:14
问题 How do you send an API request in Vapor 3 with the HTTPRequest struct? I tried variations of the following code.. var headers: HTTPHeaders = .init() let body = HTTPBody(string: a) let httpReq = HTTPRequest( method: .POST, url: URL(string: "/post")!, headers: headers, body: body) let httpRes: EventLoopFuture<HTTPResponse> = HTTPClient.connect(hostname: "httpbin.org", on: req).map(to: HTTPResponse.self) { client in return client.send(httpReq) } The compile error Cannot convert value of type '

Uploading files using Vapor

痴心易碎 提交于 2020-01-02 01:25:30
问题 I've seen in documentation in Body section that there's a support for file uploading right now - or at least I understand it this way 😅 I have no strong foundation in backend development - especially if it comes to frameworks which are still eveloving so fast as Vapor do. I wonder if someone can provide some real life example of file uploading? I was hoping for a simple web page with possibility to upload a file to the backend and then store it for future usage. 回答1: Vapor allows for file

Vapor upload multiple files at once

假如想象 提交于 2020-01-01 10:08:14
问题 I want to upload multiple images in one POST request. Currently, the part of my request related to the file upload is taking one file and looks like this: return try req.content.decode(File.self).flatMap(to: Image.self) { (file) in try file.data.write(to: URL(fileURLWithPath: DirectoryConfig.detect().workDir + localImageStorage + file.filename)) return try Image(userID: user.requireID(), url: imageStorage + file.filename, filename: file.filename).save(on: req) } This works just fine. Now, I

dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib

被刻印的时光 ゝ 提交于 2019-12-29 08:27:19
问题 I installed vapor via homebrew and then immediately wanted to jump into a project by executing vapor new Hello but then got the following message back in the terminal: dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Referenced from: /usr/local/bin/vapor Reason: image not found zsh: abort vapor new Hello I tried some approaches to fix this like uninstalling and reinstalling openssl via brew but that didn't work . Also tried something I found in the internet but nothing