File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -160,8 +160,9 @@ type GetLinkResponse struct {
160160
161161// PutFileRequest represents the JSON structure for put file operations
162162type PutFileRequest struct {
163- Key string `json:"key"`
164- Content string `json:"content"`
163+ Key string `json:"key"`
164+ Content string `json:"content"`
165+ FilePath string `json:"filePath"`
165166}
166167
167168type DeleteFileRequest struct {
Original file line number Diff line number Diff line change @@ -101,6 +101,21 @@ func (d FileStore) Save(path string, data []byte) error {
101101 return nil
102102}
103103
104+ func (d FileStore ) Upload (path string , filePath string ) error {
105+ req := PutFileRequest {
106+ Key : path ,
107+ FilePath : filePath ,
108+ }
109+
110+ err := d .client .PutFile (d .sessionId , req )
111+ if err != nil {
112+ fmt .Printf ("failed to put file: %s\n " , err .Error ())
113+ return err
114+ }
115+
116+ return nil
117+ }
118+
104119func (d FileStore ) GetUploadLink (path string ) (string , error ) {
105120 req := GetFileRequest {
106121 Key : path ,
@@ -204,6 +219,21 @@ func (f Folder) Save(name string, data []byte) error {
204219 return nil
205220}
206221
222+ func (f Folder ) Upload (name string , filePath string ) error {
223+ req := PutFileRequest {
224+ Key : f .name + "/" + name ,
225+ FilePath : filePath ,
226+ }
227+
228+ err := f .client .PutFile (f .sessionId , req )
229+ if err != nil {
230+ fmt .Printf ("failed to put file: %s\n " , err .Error ())
231+ return err
232+ }
233+
234+ return nil
235+ }
236+
207237func newFileStore (client * ServiceClient , sessionId string ) FileStore {
208238 return FileStore {
209239 client : client ,
You can’t perform that action at this time.
0 commit comments