diff --git a/http.go b/http.go index 56d304b..ea58817 100644 --- a/http.go +++ b/http.go @@ -10,8 +10,6 @@ import ( "strings" ) -var quoteEscaper = strings.NewReplacer("\\", "\\\\", `"`, "\\\"") - type loginResponse struct { Success bool `json:"success"` Message string `json:"message"` @@ -24,6 +22,8 @@ type userResponse struct { User User `json:"user"` } +var quoteEscaper = strings.NewReplacer("\\", "\\\\", `"`, "\\\"") + /* createFormFileWithMIME is a modification of multipart.CreateFormFile() that allows arbitrary mime-types. */ func createFormFileWithMIME(w *multipart.Writer, fieldname, filename string, mimeType string) (io.Writer, error) { diff --git a/upload.go b/upload.go index e3a82b3..085e276 100644 --- a/upload.go +++ b/upload.go @@ -10,7 +10,10 @@ import ( ) // UploadFile attempts to upload file from io.Readerm and returns the response -func (c Client) UploadFile(rd io.Reader, n string) (response string, error error) { +func (c Client) UploadFile(reader io.Reader, name string) (response string, error error) { + rd := reader + n := name + r, w := io.Pipe() m := multipart.NewWriter(w) go func() {