(123pan)Add Copy

This commit is contained in:
白鸟青城 2025-05-26 12:38:25 +08:00
parent ffa03bfda1
commit 9178088fb0
2 changed files with 22 additions and 2 deletions

View File

@ -13,7 +13,6 @@ import (
"github.com/alist-org/alist/v3/drivers/base"
"github.com/alist-org/alist/v3/internal/driver"
"github.com/alist-org/alist/v3/internal/errs"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/stream"
"github.com/alist-org/alist/v3/pkg/utils"
@ -164,7 +163,27 @@ func (d *Pan123) Rename(ctx context.Context, srcObj model.Obj, newName string) e
}
func (d *Pan123) Copy(ctx context.Context, srcObj, dstDir model.Obj) error {
return errs.NotSupport
if f, ok := srcObj.(File); ok {
data := base.Json{
"fileList": []map[string]interface{}{
{
"driveId": 0,
"etag": f.Etag,
"fileId": f.FileId,
"fileName": f.FileName,
"size": f.Size,
"type": f.Type,
},
},
"targetFileId": dstDir.GetID(),
}
_, err := d.Request(Copy, http.MethodPost, func(req *resty.Request) {
req.SetBody(data)
}, nil)
return err
} else {
return fmt.Errorf("can't convert srcObj to File")
}
}
func (d *Pan123) Remove(ctx context.Context, obj model.Obj) error {

View File

@ -36,6 +36,7 @@ const (
Mkdir = MainApi + "/file/upload_request"
Move = MainApi + "/file/mod_pid"
Rename = MainApi + "/file/rename"
Copy = MainApi + "/restful/goapi/v1/file/copy/async"
Trash = MainApi + "/file/trash"
UploadRequest = MainApi + "/file/upload_request"
UploadComplete = MainApi + "/file/upload_complete"