feat(onedrive): customize chunk size (close #1927)

pull/2046/head
Noah Hsu 2022-10-08 22:23:33 +08:00
parent dcaaae366b
commit 30f992c6a8
3 changed files with 5 additions and 1 deletions

View File

@ -34,6 +34,9 @@ func (d *Onedrive) Init(ctx context.Context, storage model.Storage) error {
if err != nil {
return err
}
if d.ChunkSize < 1 {
d.ChunkSize = 5
}
return d.refreshToken()
}

View File

@ -14,6 +14,7 @@ type Addition struct {
RedirectUri string `json:"redirect_uri" required:"true" default:"https://tool.nn.ci/onedrive/callback"`
RefreshToken string `json:"refresh_token" required:"true"`
SiteId string `json:"site_id"`
ChunkSize int64 `json:"chunk_size" type:"number" default:"5"`
}
var config = driver.Config{

View File

@ -166,7 +166,7 @@ func (d *Onedrive) upBig(ctx context.Context, dstDir model.Obj, stream model.Fil
}
uploadUrl := jsoniter.Get(res, "uploadUrl").ToString()
var finish int64 = 0
const DEFAULT = 100 * 1024 * 1024
DEFAULT := d.ChunkSize * 1024 * 1024
for finish < stream.GetSize() {
if utils.IsCanceled(ctx) {
return ctx.Err()