@@ -41,6 +41,10 @@ func (r *Client) CreateFileFromPath(ctx context.Context, filePath string, option
4141 }
4242 defer f .Close ()
4343
44+ if options == nil {
45+ options = & CreateFileOptions {}
46+ }
47+
4448 if options .Filename == "" {
4549 _ , options .Filename = filepath .Split (filePath )
4650 }
@@ -52,27 +56,35 @@ func (r *Client) CreateFileFromPath(ctx context.Context, filePath string, option
5256 }
5357 }
5458
55- return r .createFile (ctx , f , options )
59+ return r .createFile (ctx , f , * options )
5660}
5761
5862// CreateFileFromBytes creates a new file from bytes.
5963func (r * Client ) CreateFileFromBytes (ctx context.Context , data []byte , options * CreateFileOptions ) (* File , error ) {
6064 buf := bytes .NewBuffer (data )
6165
66+ if options == nil {
67+ options = & CreateFileOptions {}
68+ }
69+
6270 if options .ContentType == "" {
6371 options .ContentType = http .DetectContentType (data )
6472 }
6573
66- return r .createFile (ctx , buf , options )
74+ return r .createFile (ctx , buf , * options )
6775}
6876
6977// CreateFileFromBuffer creates a new file from a buffer.
7078func (r * Client ) CreateFileFromBuffer (ctx context.Context , buf * bytes.Buffer , options * CreateFileOptions ) (* File , error ) {
71- return r .createFile (ctx , buf , options )
79+ if options == nil {
80+ options = & CreateFileOptions {}
81+ }
82+
83+ return r .createFile (ctx , buf , * options )
7284}
7385
7486// CreateFile creates a new file.
75- func (r * Client ) createFile (ctx context.Context , reader io.Reader , options * CreateFileOptions ) (* File , error ) {
87+ func (r * Client ) createFile (ctx context.Context , reader io.Reader , options CreateFileOptions ) (* File , error ) {
7688 body := & bytes.Buffer {}
7789 writer := multipart .NewWriter (body )
7890
0 commit comments