@@ -88,8 +88,27 @@ func (d FileStore) Save(path string, data []byte) error {
8888 // Encode the data as base64
8989 base64Data := base64 .StdEncoding .EncodeToString (data )
9090 req := PutFileRequest {
91- Key : path ,
92- Content : base64Data ,
91+ Key : path ,
92+ TempFile : false ,
93+ Content : base64Data ,
94+ }
95+
96+ err := d .client .PutFile (d .sessionId , req )
97+ if err != nil {
98+ fmt .Printf ("failed to put file: %s\n " , err .Error ())
99+ return err
100+ }
101+
102+ return nil
103+ }
104+
105+ func (d FileStore ) SaveTemp (path string , data []byte ) error {
106+ // Encode the data as base64
107+ base64Data := base64 .StdEncoding .EncodeToString (data )
108+ req := PutFileRequest {
109+ Key : path ,
110+ TempFile : true ,
111+ Content : base64Data ,
93112 }
94113
95114 err := d .client .PutFile (d .sessionId , req )
@@ -104,6 +123,23 @@ func (d FileStore) Save(path string, data []byte) error {
104123func (d FileStore ) Upload (path string , filePath string ) error {
105124 req := PutFileRequest {
106125 Key : path ,
126+ TempFile : false ,
127+ FilePath : filePath ,
128+ }
129+
130+ err := d .client .PutFile (d .sessionId , req )
131+ if err != nil {
132+ fmt .Printf ("failed to put file: %s\n " , err .Error ())
133+ return err
134+ }
135+
136+ return nil
137+ }
138+
139+ func (d FileStore ) UploadTemp (path string , filePath string ) error {
140+ req := PutFileRequest {
141+ Key : path ,
142+ TempFile : true ,
107143 FilePath : filePath ,
108144 }
109145
@@ -117,8 +153,28 @@ func (d FileStore) Upload(path string, filePath string) error {
117153}
118154
119155func (d FileStore ) GetUploadLink (path string ) (string , error ) {
120- req := GetFileRequest {
121- Key : path ,
156+ req := GetUploadLinkRequest {
157+ Key : path ,
158+ TempFile : false ,
159+ }
160+
161+ res , err := d .client .GetFileUploadLink (d .sessionId , req )
162+ if err != nil {
163+ fmt .Printf ("failed to get file link: %s\n " , err .Error ())
164+ return "" , err
165+ }
166+
167+ if res .Link == "" {
168+ return "" , errors .New ("empty link" )
169+ }
170+
171+ return res .Link , nil
172+ }
173+
174+ func (d FileStore ) GetTempUploadLink (path string ) (string , error ) {
175+ req := GetUploadLinkRequest {
176+ Key : path ,
177+ TempFile : true ,
122178 }
123179
124180 res , err := d .client .GetFileUploadLink (d .sessionId , req )
@@ -206,8 +262,27 @@ func (f Folder) Save(name string, data []byte) error {
206262 // Encode the data as base64
207263 base64Data := base64 .StdEncoding .EncodeToString (data )
208264 req := PutFileRequest {
209- Key : f .name + "/" + name ,
210- Content : base64Data ,
265+ Key : f .name + "/" + name ,
266+ TempFile : false ,
267+ Content : base64Data ,
268+ }
269+
270+ err := f .client .PutFile (f .sessionId , req )
271+ if err != nil {
272+ fmt .Printf ("failed to put file: %s\n " , err .Error ())
273+ return err
274+ }
275+
276+ return nil
277+ }
278+
279+ func (f Folder ) SaveTemp (name string , data []byte ) error {
280+ // Encode the data as base64
281+ base64Data := base64 .StdEncoding .EncodeToString (data )
282+ req := PutFileRequest {
283+ Key : f .name + "/" + name ,
284+ TempFile : true ,
285+ Content : base64Data ,
211286 }
212287
213288 err := f .client .PutFile (f .sessionId , req )
@@ -222,6 +297,23 @@ func (f Folder) Save(name string, data []byte) error {
222297func (f Folder ) Upload (name string , filePath string ) error {
223298 req := PutFileRequest {
224299 Key : f .name + "/" + name ,
300+ TempFile : false ,
301+ FilePath : filePath ,
302+ }
303+
304+ err := f .client .PutFile (f .sessionId , req )
305+ if err != nil {
306+ fmt .Printf ("failed to put file: %s\n " , err .Error ())
307+ return err
308+ }
309+
310+ return nil
311+ }
312+
313+ func (f Folder ) UploadTemp (name string , filePath string ) error {
314+ req := PutFileRequest {
315+ Key : f .name + "/" + name ,
316+ TempFile : true ,
225317 FilePath : filePath ,
226318 }
227319
0 commit comments