Vapor client close stream -


app upload through interface server, server , upload picture storage space.i know method not best if there ways thank share

code this:

with main.swift

let config = try config() try config.addprovider(postgresqlprovider.provider.self)  let drop = try droplet(config)  let flecrl = filecontroller(); flecrl.addroutest(drop: drop); drop.resource("files", flecrl); 

with filecontroller.swift

final class filecontroller: resourcerepresentable{  var drop:droplet?;  public func addroutest(drop: droplet) -> void {     self.drop = drop;     let d = drop.grouped("file");     d.post("updatefile", handler: updatefile) }  func updatefile(req:request) throws -> responserepresentable {      let picname =  req.data["name"]?.string ?? string();     let bytes:[uint8] = (req.data["data"]?.bytes)!;     let request = request(method:.post,uri:"http://up.qiniu.com");      let t = "image/\(picname)";     let token = req.data["token"]?.bytes;      request.formdata = [         "token":field(name:"token",filename:nil,part:part(headers:[:], body: token!)),         "file":field(name:"file",filename:t,part:part(headers:["content-type": "vnd.apple.mpegurl"],body:bytes)),         "key":field(name:"key",filename:t,part:part(headers:[:],body:t.bytes))     ]      let resp = try self.drop?.client.respond(to: request);      return resp?.data["info"]?.string;    }  } 

with client

    let data = try data.init(contentsof: url.init(string: "video.m3u8")!);      alamofire.upload(multipartformdata: { (multipartformdata) in          multipartformdata.append(data!, withname: "data", filename: "video", mimetype:"application/x-mpegurl")          multipartformdata.append("videoname".data(using: .utf8)!, withname: "name")      }, to: "http://0.0.0.0:8083/file/updatefile") { (encodingresult) in          switch encodingresult {         case .success(let upload, _, _):             upload.responsejson { response in                 debugprint(response)             }         case .failure(let encodingerror):             print(encodingerror)         }     } 

the server console reported follows

[stream error: stream closed] [identifier: transport.streamerror.closed] 


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -