 
             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]]
 

            autoreleasepool {

                let formData = self.formDataForParams(boundary, dictWithParam: dictWithParam, ending: "\r\n")
                fwrite(formData.bytes, 1, formData.length, file)
            }
        }

        fclose(file)

        return filePath
    }

        var filePath = NSUUID().UUIDString

        filePath = String.cachesPathByAppendingPathComponent(filePath)

        NSFileManager.defaultManager().createFileAtPath(filePath, contents: nil, attributes: nil)

        let file = NSFileHandle(forWritingAtPath: filePath)!

        autoreleasepool {

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

