|
|
|
@ -2,10 +2,12 @@ package alist_v3
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"io"
|
|
|
|
|
"path"
|
|
|
|
|
"strconv"
|
|
|
|
|
|
|
|
|
|
"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/pkg/utils"
|
|
|
|
|
"github.com/alist-org/alist/v3/server/common"
|
|
|
|
@ -100,27 +102,86 @@ func (d *AListV3) Link(ctx context.Context, file model.Obj, args model.LinkArgs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (d *AListV3) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error {
|
|
|
|
|
return errs.NotImplement
|
|
|
|
|
url := d.Address + "/api/fs/mkdir"
|
|
|
|
|
var resp common.Resp[interface{}]
|
|
|
|
|
_, err := base.RestyClient.R().
|
|
|
|
|
SetResult(&resp).
|
|
|
|
|
SetHeader("Authorization", d.AccessToken).
|
|
|
|
|
SetBody(MkdirOrLinkReq{
|
|
|
|
|
Path: path.Join(parentDir.GetPath(), dirName),
|
|
|
|
|
}).Post(url)
|
|
|
|
|
return checkResp(resp, err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (d *AListV3) Move(ctx context.Context, srcObj, dstDir model.Obj) error {
|
|
|
|
|
return errs.NotImplement
|
|
|
|
|
url := d.Address + "/api/fs/move"
|
|
|
|
|
var resp common.Resp[interface{}]
|
|
|
|
|
_, err := base.RestyClient.R().
|
|
|
|
|
SetResult(&resp).
|
|
|
|
|
SetHeader("Authorization", d.AccessToken).
|
|
|
|
|
SetBody(MoveCopyReq{
|
|
|
|
|
SrcDir: srcObj.GetPath(),
|
|
|
|
|
DstDir: dstDir.GetPath(),
|
|
|
|
|
Names: []string{srcObj.GetName()},
|
|
|
|
|
}).Post(url)
|
|
|
|
|
return checkResp(resp, err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (d *AListV3) Rename(ctx context.Context, srcObj model.Obj, newName string) error {
|
|
|
|
|
return errs.NotImplement
|
|
|
|
|
url := d.Address + "/api/fs/rename"
|
|
|
|
|
var resp common.Resp[interface{}]
|
|
|
|
|
_, err := base.RestyClient.R().
|
|
|
|
|
SetResult(&resp).
|
|
|
|
|
SetHeader("Authorization", d.AccessToken).
|
|
|
|
|
SetBody(RenameReq{
|
|
|
|
|
Path: srcObj.GetPath(),
|
|
|
|
|
Name: newName,
|
|
|
|
|
}).Post(url)
|
|
|
|
|
return checkResp(resp, err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (d *AListV3) Copy(ctx context.Context, srcObj, dstDir model.Obj) error {
|
|
|
|
|
return errs.NotImplement
|
|
|
|
|
url := d.Address + "/api/fs/copy"
|
|
|
|
|
var resp common.Resp[interface{}]
|
|
|
|
|
_, err := base.RestyClient.R().
|
|
|
|
|
SetResult(&resp).
|
|
|
|
|
SetHeader("Authorization", d.AccessToken).
|
|
|
|
|
SetBody(MoveCopyReq{
|
|
|
|
|
SrcDir: srcObj.GetPath(),
|
|
|
|
|
DstDir: dstDir.GetPath(),
|
|
|
|
|
Names: []string{srcObj.GetName()},
|
|
|
|
|
}).Post(url)
|
|
|
|
|
return checkResp(resp, err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (d *AListV3) Remove(ctx context.Context, obj model.Obj) error {
|
|
|
|
|
return errs.NotImplement
|
|
|
|
|
url := d.Address + "/api/fs/remove"
|
|
|
|
|
var resp common.Resp[interface{}]
|
|
|
|
|
_, err := base.RestyClient.R().
|
|
|
|
|
SetResult(&resp).
|
|
|
|
|
SetHeader("Authorization", d.AccessToken).
|
|
|
|
|
SetBody(RemoveReq{
|
|
|
|
|
Dir: obj.GetPath(),
|
|
|
|
|
Names: []string{obj.GetName()},
|
|
|
|
|
}).Post(url)
|
|
|
|
|
return checkResp(resp, err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (d *AListV3) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) error {
|
|
|
|
|
return errs.NotImplement
|
|
|
|
|
url := d.Address + "/api/fs/put"
|
|
|
|
|
var resp common.Resp[interface{}]
|
|
|
|
|
fileBytes, err := io.ReadAll(stream.GetReadCloser())
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
_, err = base.RestyClient.R().
|
|
|
|
|
SetResult(&resp).
|
|
|
|
|
SetHeader("Authorization", d.AccessToken).
|
|
|
|
|
SetHeader("File-Path", path.Join(dstDir.GetPath(), stream.GetName())).
|
|
|
|
|
SetHeader("Password", d.Password).
|
|
|
|
|
SetHeader("Content-Length", strconv.FormatInt(stream.GetSize(), 10)).
|
|
|
|
|
SetBody(fileBytes).Put(url)
|
|
|
|
|
return checkResp(resp, err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//func (d *AList) Other(ctx context.Context, args model.OtherArgs) (interface{}, error) {
|
|
|
|
|