@@ -98,12 +98,11 @@ func (c *Client) CreateFile(ctx context.Context, request FileRequest) (file File
9898
9999 w .Close ()
100100
101- req , err := http .NewRequest ( "POST" , c .fullURL ("/files" ), & b )
101+ req , err := http .NewRequestWithContext ( ctx , http . MethodPost , c .fullURL ("/files" ), & b )
102102 if err != nil {
103103 return
104104 }
105105
106- req = req .WithContext (ctx )
107106 req .Header .Set ("Content-Type" , w .FormDataContentType ())
108107
109108 err = c .sendRequest (req , & file )
@@ -113,25 +112,23 @@ func (c *Client) CreateFile(ctx context.Context, request FileRequest) (file File
113112
114113// DeleteFile deletes an existing file.
115114func (c * Client ) DeleteFile (ctx context.Context , fileID string ) (err error ) {
116- req , err := http .NewRequest ( "DELETE" , c .fullURL ("/files/" + fileID ), nil )
115+ req , err := http .NewRequestWithContext ( ctx , http . MethodDelete , c .fullURL ("/files/" + fileID ), nil )
117116 if err != nil {
118117 return
119118 }
120119
121- req = req .WithContext (ctx )
122120 err = c .sendRequest (req , nil )
123121 return
124122}
125123
126124// ListFiles Lists the currently available files,
127125// and provides basic information about each file such as the file name and purpose.
128126func (c * Client ) ListFiles (ctx context.Context ) (files FilesList , err error ) {
129- req , err := http .NewRequest ( "GET" , c .fullURL ("/files" ), nil )
127+ req , err := http .NewRequestWithContext ( ctx , http . MethodGet , c .fullURL ("/files" ), nil )
130128 if err != nil {
131129 return
132130 }
133131
134- req = req .WithContext (ctx )
135132 err = c .sendRequest (req , & files )
136133 return
137134}
@@ -140,12 +137,11 @@ func (c *Client) ListFiles(ctx context.Context) (files FilesList, err error) {
140137// such as the file name and purpose.
141138func (c * Client ) GetFile (ctx context.Context , fileID string ) (file File , err error ) {
142139 urlSuffix := fmt .Sprintf ("/files/%s" , fileID )
143- req , err := http .NewRequest ( "GET" , c .fullURL (urlSuffix ), nil )
140+ req , err := http .NewRequestWithContext ( ctx , http . MethodGet , c .fullURL (urlSuffix ), nil )
144141 if err != nil {
145142 return
146143 }
147144
148- req = req .WithContext (ctx )
149145 err = c .sendRequest (req , & file )
150146 return
151147}
0 commit comments