 
             let contentDisposition = "Content-Disposition: form-data; name=\"\(name)\"; filename=\"\(fileName)\"\r\n"
             let contentDispositionData = contentDisposition.dataUsingEncoding(NSUTF8StringEncoding)!
-            fwrite(contentDispositionData.bytes, 1, contentDispositionData.length, file)
+            file.writeData(contentDispositionData)
         }
         //[result appendData:[[[NSString alloc] initWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n", parameter, fileName] dataUsingEncoding:NSUTF8StringEncoding]]
 

        var filePath = NSUUID().UUIDString

        filePath = String.cachesPathByAppendingPathComponent(filePath)
        let filePathPtr = filePath.cStringUsingEncoding(NSUTF8StringEncoding)

        let file = fopen(filePathPtr!, "w+")

        autoreleasepool {

            let boundaryStr  = "--\(boundary)\r\n"
            let boundaryData = boundaryStr.dataUsingEncoding(NSUTF8StringEncoding)!
            fwrite(boundaryData.bytes, 1, boundaryData.length, file)
        }
        //[result appendData:[[[NSString alloc] initWithFormat:@"--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]]


            let contentTypeStr  = contentType ?? "application/octet-stream"
            let contentTypeSrv  = "Content-Type: \(contentTypeStr)\r\n\r\n"
            let contentTypeData = contentTypeSrv.dataUsingEncoding(NSUTF8StringEncoding)!
            file.writeData(contentTypeData)
        }
        //[result appendData:[@"Content-Type: application/octet-stream\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]]

        autoreleasepool {

            let uploadDataFile = NSFileHandle(forReadingAtPath: dataFilePath)!

            let chunkSize = 10*1024

            var readBytes = uploadDataFile.readDataOfLength(chunkSize)

            while readBytes.length != 0 {

                file.writeData(readBytes)
                readBytes = uploadDataFile.readDataOfLength(chunkSize)
            }

            uploadDataFile.closeFile()
        }
        //[result appendData:data]

