虽然响应是成功的,但服务器不接收音频文件URL

时间:2018-03-07 17:10:48

标签: ios swift swift3 avfoundation alamofire

所以我正在尝试将我的音频文件上传到服务器。

从服务器我需要完成这些事情:

messages/create -> route
type: POST
mandatory:
message_token  // message_token must be generated unique
message  // type FILE => message_token + message_id + owner_id + .amr
duration // example: 4000, means 4 sec
general: user_token ,source, version 

response if success:
{
status: "success",
message: "Conversation has been successfully created!",

在我的代码中,我使用Alamofire进行http请求。

    func createMessage() {
    let url = URL(string: Helper.apiUrl + "messages/create")
    Alamofire.upload(multipartFormData: { (multiplePartFormData) in
        let appVersion = Bundle.main.infoDictionary!["CFBundleShortVersionString"]
        let duration = 4000

        var multiplePartFormData: Dictionary<String, Any> = ["message_token": self.curentFileName ?? 0,
                                                  "duration": duration,
                                                  "user_token" : userDefaults.value(forKey: "user_token") as! String,
                                                  "source":"ios",
                                                  "version":"\(String(describing: appVersion!))"]




        do {
           let soundfile = try Data.init(contentsOf: self.soundFileURL)
            multiplePartFormData["message"] = soundfile
        } catch {

        }
    }, usingThreshold: UInt64(), to: url!, method: .post, headers: nil) { (result) in
        print(result)
        switch result {
        case .success:
            print("succes")
        case .failure:
            print("fail")
        }
    }
}

事情是在服务器上我没有收到任何东西,令人沮丧的是响应是成功的......

  

授予Permision   写入soundfile url:'file:/// 66974D10D61 / data / Containers / Data / Application / 494935E8-1E8D-48D6-8577-84E84B3D97B0 / Documents / Optional(2018030718503271072).37.m4a'

     

成功(请求:2018-03-07 18:50:34.670385 + 0200 VoiceMe [36784:1559418] CredStore - performQuery - 错误复制匹配的信用卡。错误= -25300,

 query={
    atyp = http;
    class = inet;
    "m_Limit" = "m_LimitAll";
    ptcl = http;
    "r_Attributes" = 1;
    sdmn = "v.site.com";
    srvr = "v.site.com";
    sync = syna;
}
  

$ curl -v \ -X POST \ -H“Content-Type:multipart / form-data;   boundary = alamofire.boundary.c0201af3574a47dd“\ -H”Accept-Language:   en; q = 1.0“\ -H”User-Agent:VoiceMe / 1.0(; build:1; iOS 11.2.0)   Alamofire / 4.6.0“\ -H”接受编码:gzip; q = 1.0,压缩; q = 0.5“\     “http://blabla/pi/v1/messages/create”,streamingFromDisk:true,   streamFileURL:   可选(文件:///Users/Library/Developer/CoreSimulator/Devices/E65D9E9F-7553-4C3F-A7D9D61/data/Containers/Data/Application/494935E8-1E8D-48D6-8577-84E84B3D97B0/tmp/org.alamofire.manager /multipart.form.data/9B16CF74-A6BC-4AC7-89E8-68633E5DB91E))

     

更迭

有人遇到过这个问题吗?或者有任何想法?升值。

0 个答案:

没有答案