Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
eb15bce24b | |||
52814266b8 | |||
f845ec05e0 | |||
29fb02c886 | |||
072e854a71 | |||
cae0a5f603 | |||
7c6d8ca222 | |||
f6be50f15a | |||
c35d54d092 | |||
323dad2a1c | |||
62aefc4f68 | |||
6a7eb8b3eb | |||
eb549f2631 | |||
9207eb69ee | |||
866df0540b | |||
04e04a1aa6 | |||
6a66e39d5b | |||
f2b2728be7 | |||
39b8f28fc4 |
@ -78,11 +78,20 @@
|
|||||||
"contributions": [
|
"contributions": [
|
||||||
"code"
|
"code"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"login": "XZB-1248",
|
||||||
|
"name": "XZB-1248",
|
||||||
|
"avatar_url": "https://avatars.githubusercontent.com/u/28593573?v=4",
|
||||||
|
"profile": "https://github.com/XZB-1248",
|
||||||
|
"contributions": [
|
||||||
|
"code"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"contributorsPerLine": 7,
|
"contributorsPerLine": 7,
|
||||||
"projectName": "alist",
|
"projectName": "alist",
|
||||||
"projectOwner": "Xhofe",
|
"projectOwner": "alist-org",
|
||||||
"repoType": "github",
|
"repoType": "github",
|
||||||
"repoHost": "https://github.com",
|
"repoHost": "https://github.com",
|
||||||
"skipCi": true
|
"skipCi": true
|
||||||
|
26
.github/workflows/release.yml
vendored
26
.github/workflows/release.yml
vendored
@ -6,7 +6,33 @@ on:
|
|||||||
- '*'
|
- '*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
changelog:
|
||||||
|
name: Create Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Changelog
|
||||||
|
uses: Bullrich/generate-release-changelog@master
|
||||||
|
id: Changelog
|
||||||
|
env:
|
||||||
|
REPO: ${{ github.repository }}
|
||||||
|
- name: Create Release
|
||||||
|
id: create_release
|
||||||
|
uses: actions/create-release@latest
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
|
||||||
|
with:
|
||||||
|
tag_name: ${{ github.ref }}
|
||||||
|
release_name: Release ${{ github.ref }}
|
||||||
|
body: |
|
||||||
|
${{ steps.Changelog.outputs.changelog }}
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
release:
|
release:
|
||||||
|
needs: changelog
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
platform: [ubuntu-latest]
|
platform: [ubuntu-latest]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
||||||
[](#contributors-)
|
[](#contributors-)
|
||||||
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
||||||
|
|
||||||
## Contributors ✨
|
## Contributors ✨
|
||||||
@ -11,16 +11,17 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|||||||
<!-- markdownlint-disable -->
|
<!-- markdownlint-disable -->
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center"><a href="http://nn.ci"><img src="https://avatars.githubusercontent.com/u/36558727?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Xhofe</b></sub></a><br /><a href="https://github.com/Xhofe/alist/commits?author=Xhofe" title="Code">💻</a> <a href="#ideas-Xhofe" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/Xhofe/alist/commits?author=Xhofe" title="Documentation">📖</a></td>
|
<td align="center"><a href="http://nn.ci"><img src="https://avatars.githubusercontent.com/u/36558727?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Xhofe</b></sub></a><br /><a href="https://github.com/alist-org/alist/commits?author=Xhofe" title="Code">💻</a> <a href="#ideas-Xhofe" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/alist-org/alist/commits?author=Xhofe" title="Documentation">📖</a></td>
|
||||||
<td align="center"><a href="https://github.com/foxxorcat"><img src="https://avatars.githubusercontent.com/u/95907542?v=4?s=100" width="100px;" alt=""/><br /><sub><b>foxxorcat</b></sub></a><br /><a href="https://github.com/Xhofe/alist/commits?author=foxxorcat" title="Code">💻</a></td>
|
<td align="center"><a href="https://github.com/foxxorcat"><img src="https://avatars.githubusercontent.com/u/95907542?v=4?s=100" width="100px;" alt=""/><br /><sub><b>foxxorcat</b></sub></a><br /><a href="https://github.com/alist-org/alist/commits?author=foxxorcat" title="Code">💻</a></td>
|
||||||
<td align="center"><a href="https://www.iflu.cf/"><img src="https://avatars.githubusercontent.com/u/63903027?v=4?s=100" width="100px;" alt=""/><br /><sub><b>道辰</b></sub></a><br /><a href="https://github.com/Xhofe/alist/commits?author=DaoChen6" title="Documentation">📖</a></td>
|
<td align="center"><a href="https://www.iflu.cf/"><img src="https://avatars.githubusercontent.com/u/63903027?v=4?s=100" width="100px;" alt=""/><br /><sub><b>道辰</b></sub></a><br /><a href="https://github.com/alist-org/alist/commits?author=DaoChen6" title="Documentation">📖</a></td>
|
||||||
<td align="center"><a href="https://vg-land.github.io/"><img src="https://avatars.githubusercontent.com/u/16739728?v=4?s=100" width="100px;" alt=""/><br /><sub><b>vg-land</b></sub></a><br /><a href="https://github.com/Xhofe/alist/commits?author=vg-land" title="Code">💻</a></td>
|
<td align="center"><a href="https://vg-land.github.io/"><img src="https://avatars.githubusercontent.com/u/16739728?v=4?s=100" width="100px;" alt=""/><br /><sub><b>vg-land</b></sub></a><br /><a href="https://github.com/alist-org/alist/commits?author=vg-land" title="Code">💻</a></td>
|
||||||
<td align="center"><a href="https://c5y.moe"><img src="https://avatars.githubusercontent.com/u/18461360?v=4?s=100" width="100px;" alt=""/><br /><sub><b>凌莞~(=^▽^=)</b></sub></a><br /><a href="https://github.com/Xhofe/alist/commits?author=Clansty" title="Documentation">📖</a></td>
|
<td align="center"><a href="https://c5y.moe"><img src="https://avatars.githubusercontent.com/u/18461360?v=4?s=100" width="100px;" alt=""/><br /><sub><b>凌莞~(=^▽^=)</b></sub></a><br /><a href="https://github.com/alist-org/alist/commits?author=Clansty" title="Documentation">📖</a></td>
|
||||||
<td align="center"><a href="https://github.com/Windman1320"><img src="https://avatars.githubusercontent.com/u/9999486?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Windman</b></sub></a><br /><a href="https://github.com/Xhofe/alist/commits?author=Windman1320" title="Code">💻</a></td>
|
<td align="center"><a href="https://github.com/Windman1320"><img src="https://avatars.githubusercontent.com/u/9999486?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Windman</b></sub></a><br /><a href="https://github.com/alist-org/alist/commits?author=Windman1320" title="Code">💻</a></td>
|
||||||
<td align="center"><a href="https://github.com/ericarena"><img src="https://avatars.githubusercontent.com/u/4518927?v=4?s=100" width="100px;" alt=""/><br /><sub><b>ericarena</b></sub></a><br /><a href="https://github.com/Xhofe/alist/commits?author=ericarena" title="Code">💻</a></td>
|
<td align="center"><a href="https://github.com/ericarena"><img src="https://avatars.githubusercontent.com/u/4518927?v=4?s=100" width="100px;" alt=""/><br /><sub><b>ericarena</b></sub></a><br /><a href="https://github.com/alist-org/alist/commits?author=ericarena" title="Code">💻</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center"><a href="https://github.com/WntFlm"><img src="https://avatars.githubusercontent.com/u/34620278?v=4?s=100" width="100px;" alt=""/><br /><sub><b>WntFlm</b></sub></a><br /><a href="https://github.com/Xhofe/alist/commits?author=WntFlm" title="Code">💻</a></td>
|
<td align="center"><a href="https://github.com/WntFlm"><img src="https://avatars.githubusercontent.com/u/34620278?v=4?s=100" width="100px;" alt=""/><br /><sub><b>WntFlm</b></sub></a><br /><a href="https://github.com/alist-org/alist/commits?author=WntFlm" title="Code">💻</a></td>
|
||||||
|
<td align="center"><a href="https://github.com/XZB-1248"><img src="https://avatars.githubusercontent.com/u/28593573?v=4?s=100" width="100px;" alt=""/><br /><sub><b>XZB-1248</b></sub></a><br /><a href="https://github.com/alist-org/alist/commits?author=XZB-1248" title="Code">💻</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
@ -124,6 +124,13 @@ func InitSettings() {
|
|||||||
Access: model.PUBLIC,
|
Access: model.PUBLIC,
|
||||||
Group: model.FRONT,
|
Group: model.FRONT,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Key: "pdf viewer url",
|
||||||
|
Type: "string",
|
||||||
|
Value: "https://alist-org.github.io/pdf.js/web/viewer.html?file=$url",
|
||||||
|
Access: model.PUBLIC,
|
||||||
|
Group: model.FRONT,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Key: "autoplay video",
|
Key: "autoplay video",
|
||||||
Value: "false",
|
Value: "false",
|
||||||
|
@ -40,7 +40,7 @@ var (
|
|||||||
"go", "sh", "c", "cpp", "h", "hpp", "tsx", "vtt", "srt", "ass"}
|
"go", "sh", "c", "cpp", "h", "hpp", "tsx", "vtt", "srt", "ass"}
|
||||||
DProxyTypes = []string{"m3u8"}
|
DProxyTypes = []string{"m3u8"}
|
||||||
OfficeTypes = []string{"doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf"}
|
OfficeTypes = []string{"doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf"}
|
||||||
VideoTypes = []string{"mp4", "mkv", "avi", "mov", "rmvb", "webm", "flv"}
|
VideoTypes = []string{"mp4", "mkv", "avi", "mov", "rmvb", "webm", "flv", "m4v"}
|
||||||
AudioTypes = []string{"mp3", "flac", "ogg", "m4a", "wav", "opus"}
|
AudioTypes = []string{"mp3", "flac", "ogg", "m4a", "wav", "opus"}
|
||||||
ImageTypes = []string{"jpg", "tiff", "jpeg", "png", "gif", "bmp", "svg", "ico", "swf", "webp"}
|
ImageTypes = []string{"jpg", "tiff", "jpeg", "png", "gif", "bmp", "svg", "ico", "swf", "webp"}
|
||||||
)
|
)
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package _23
|
package _23
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
|
"encoding/binary"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -68,6 +70,12 @@ func (driver Pan123) Items() []base.Item {
|
|||||||
Required: true,
|
Required: true,
|
||||||
Default: "asc",
|
Default: "asc",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "bool_1",
|
||||||
|
Label: "stream upload",
|
||||||
|
Type: base.TypeBool,
|
||||||
|
Description: "io stream upload (test)",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,23 +310,44 @@ func (driver Pan123) Upload(file *model.FileStream, account *model.Account) erro
|
|||||||
return base.ErrNotFolder
|
return base.ErrNotFolder
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DEFAULT int64 = 10485760
|
||||||
|
var uploadFile io.Reader
|
||||||
|
h := md5.New()
|
||||||
|
if account.Bool1 && file.GetSize() > uint64(DEFAULT) {
|
||||||
|
// 只计算前10MIB
|
||||||
|
buf := bytes.NewBuffer(make([]byte, 0, DEFAULT))
|
||||||
|
if n, err := io.CopyN(io.MultiWriter(buf, h), file, DEFAULT); err != io.EOF && n == 0 {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// 增加额外参数防止MD5碰撞
|
||||||
|
h.Write([]byte(file.Name))
|
||||||
|
num := make([]byte, 8)
|
||||||
|
binary.BigEndian.PutUint64(num, file.Size)
|
||||||
|
h.Write(num)
|
||||||
|
// 拼装
|
||||||
|
uploadFile = io.MultiReader(buf, file)
|
||||||
|
} else {
|
||||||
|
// 计算完整文件MD5
|
||||||
tempFile, err := ioutil.TempFile(conf.Conf.TempDir, "file-*")
|
tempFile, err := ioutil.TempFile(conf.Conf.TempDir, "file-*")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer tempFile.Close()
|
defer func() {
|
||||||
defer os.Remove(tempFile.Name())
|
_ = tempFile.Close()
|
||||||
h := md5.New()
|
_ = os.Remove(tempFile.Name())
|
||||||
|
}()
|
||||||
|
|
||||||
if _, err = io.Copy(io.MultiWriter(tempFile, h), file); err != nil {
|
if _, err = io.Copy(io.MultiWriter(tempFile, h), file); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
etag := hex.EncodeToString(h.Sum(nil))
|
|
||||||
|
|
||||||
_, err = tempFile.Seek(0, io.SeekStart)
|
_, err = tempFile.Seek(0, io.SeekStart)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
uploadFile = tempFile
|
||||||
|
}
|
||||||
|
etag := hex.EncodeToString(h.Sum(nil))
|
||||||
data := base.Json{
|
data := base.Json{
|
||||||
"driveId": 0,
|
"driveId": 0,
|
||||||
"duplicate": 2, // 2->覆盖 1->重命名 0->默认
|
"duplicate": 2, // 2->覆盖 1->重命名 0->默认
|
||||||
@ -352,7 +381,7 @@ func (driver Pan123) Upload(file *model.FileStream, account *model.Account) erro
|
|||||||
input := &s3manager.UploadInput{
|
input := &s3manager.UploadInput{
|
||||||
Bucket: &resp.Data.Bucket,
|
Bucket: &resp.Data.Bucket,
|
||||||
Key: &resp.Data.Key,
|
Key: &resp.Data.Key,
|
||||||
Body: tempFile,
|
Body: uploadFile,
|
||||||
}
|
}
|
||||||
_, err = uploader.Upload(input)
|
_, err = uploader.Upload(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -7,6 +7,14 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"math"
|
||||||
|
"net/http"
|
||||||
|
"regexp"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/Xhofe/alist/conf"
|
"github.com/Xhofe/alist/conf"
|
||||||
"github.com/Xhofe/alist/drivers/base"
|
"github.com/Xhofe/alist/drivers/base"
|
||||||
"github.com/Xhofe/alist/model"
|
"github.com/Xhofe/alist/model"
|
||||||
@ -14,14 +22,6 @@ import (
|
|||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"io"
|
|
||||||
"math"
|
|
||||||
"net/http"
|
|
||||||
"net/http/cookiejar"
|
|
||||||
"regexp"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var client189Map map[string]*resty.Client
|
var client189Map map[string]*resty.Client
|
||||||
@ -94,18 +94,12 @@ type LoginResp struct {
|
|||||||
|
|
||||||
// Login refer to PanIndex
|
// Login refer to PanIndex
|
||||||
func (driver Cloud189) Login(account *model.Account) error {
|
func (driver Cloud189) Login(account *model.Account) error {
|
||||||
client, ok := client189Map[account.Name]
|
client := resty.New()
|
||||||
if !ok {
|
|
||||||
//cookieJar, _ := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
|
|
||||||
client = resty.New()
|
|
||||||
//client.SetCookieJar(cookieJar)
|
//client.SetCookieJar(cookieJar)
|
||||||
client.SetTimeout(base.DefaultTimeout)
|
client.SetTimeout(base.DefaultTimeout)
|
||||||
client.SetRetryCount(3)
|
client.SetRetryCount(3)
|
||||||
client.SetHeader("Referer", "https://cloud.189.cn/")
|
client.SetHeader("Referer", "https://cloud.189.cn/")
|
||||||
}
|
client.SetHeader("User-Agent", base.UserAgent)
|
||||||
// clear cookie
|
|
||||||
jar, _ := cookiejar.New(nil)
|
|
||||||
client.SetCookieJar(jar)
|
|
||||||
url := "https://cloud.189.cn/api/portal/loginUrl.action?redirectURL=https%3A%2F%2Fcloud.189.cn%2Fmain.action"
|
url := "https://cloud.189.cn/api/portal/loginUrl.action?redirectURL=https%3A%2F%2Fcloud.189.cn%2Fmain.action"
|
||||||
b := ""
|
b := ""
|
||||||
lt := ""
|
lt := ""
|
||||||
@ -131,7 +125,8 @@ func (driver Cloud189) Login(account *model.Account) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if lt == "" {
|
if lt == "" {
|
||||||
return fmt.Errorf("get page: %s \nstatus: %d \nrequest url: %s", b, res.StatusCode(), res.RawResponse.Request.URL.String())
|
return fmt.Errorf("get page: %s \nstatus: %d \nrequest url: %s\nredirect url: %s",
|
||||||
|
b, res.StatusCode(), res.RawResponse.Request.URL.String(), res.Header().Get("location"))
|
||||||
}
|
}
|
||||||
captchaToken := regexp.MustCompile(`captchaToken' value='(.+?)'`).FindStringSubmatch(b)[1]
|
captchaToken := regexp.MustCompile(`captchaToken' value='(.+?)'`).FindStringSubmatch(b)[1]
|
||||||
returnUrl := regexp.MustCompile(`returnUrl = '(.+?)'`).FindStringSubmatch(b)[1]
|
returnUrl := regexp.MustCompile(`returnUrl = '(.+?)'`).FindStringSubmatch(b)[1]
|
||||||
|
@ -2,15 +2,16 @@ package _89
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/Xhofe/alist/conf"
|
"github.com/Xhofe/alist/conf"
|
||||||
"github.com/Xhofe/alist/drivers/base"
|
"github.com/Xhofe/alist/drivers/base"
|
||||||
"github.com/Xhofe/alist/model"
|
"github.com/Xhofe/alist/model"
|
||||||
"github.com/Xhofe/alist/utils"
|
"github.com/Xhofe/alist/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"net/http"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Cloud189 struct{}
|
type Cloud189 struct{}
|
||||||
@ -179,23 +180,27 @@ func (driver Cloud189) Link(args base.Args, account *model.Account) (*base.Link,
|
|||||||
resty.RedirectPolicyFunc(func(req *http.Request, via []*http.Request) error {
|
resty.RedirectPolicyFunc(func(req *http.Request, via []*http.Request) error {
|
||||||
return http.ErrUseLastResponse
|
return http.ErrUseLastResponse
|
||||||
}))
|
}))
|
||||||
res, err := client.R().Get("https:" + resp.FileDownloadUrl)
|
res, err := client.R().SetHeader("User-Agent", base.UserAgent).Get("https:" + resp.FileDownloadUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
log.Debugln(res.Status())
|
log.Debugln(res.Status())
|
||||||
|
log.Debugln(res.String())
|
||||||
link := base.Link{
|
link := base.Link{
|
||||||
Headers: []base.Header{
|
Headers: []base.Header{
|
||||||
{Name: "User-Agent", Value: base.UserAgent},
|
{Name: "User-Agent", Value: base.UserAgent},
|
||||||
//{Name: "Authorization", Value: ""},
|
//{Name: "Authorization", Value: ""},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
log.Debugln("first url:", resp.FileDownloadUrl)
|
||||||
if res.StatusCode() == 302 {
|
if res.StatusCode() == 302 {
|
||||||
link.Url = res.Header().Get("location")
|
link.Url = res.Header().Get("location")
|
||||||
res, err = client.R().Get(link.Url)
|
log.Debugln("second url:", link.Url)
|
||||||
|
_, _ = client.R().Get(link.Url)
|
||||||
if res.StatusCode() == 302 {
|
if res.StatusCode() == 302 {
|
||||||
link.Url = res.Header().Get("location")
|
link.Url = res.Header().Get("location")
|
||||||
}
|
}
|
||||||
|
log.Debugln("third url:", link.Url)
|
||||||
} else {
|
} else {
|
||||||
link.Url = resp.FileDownloadUrl
|
link.Url = resp.FileDownloadUrl
|
||||||
}
|
}
|
||||||
|
@ -607,7 +607,7 @@ func (driver Cloud189) CommonUpload(file *model.FileStream, parentFile *model.Fi
|
|||||||
|
|
||||||
uploadData := uploadUrl.UploadUrls[fmt.Sprint("partNumber_", i)]
|
uploadData := uploadUrl.UploadUrls[fmt.Sprint("partNumber_", i)]
|
||||||
req, _ := http.NewRequest(http.MethodPut, uploadData.RequestURL, byteData)
|
req, _ := http.NewRequest(http.MethodPut, uploadData.RequestURL, byteData)
|
||||||
req.Header.Del("User-Agent")
|
req.Header.Set("User-Agent", "")
|
||||||
for k, v := range ParseHttpHeader(uploadData.RequestHeader) {
|
for k, v := range ParseHttpHeader(uploadData.RequestHeader) {
|
||||||
req.Header.Set(k, v)
|
req.Header.Set(k, v)
|
||||||
}
|
}
|
||||||
@ -650,9 +650,10 @@ func (driver Cloud189) FastUpload(file *model.FileStream, parentFile *model.File
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer tempFile.Close()
|
defer func() {
|
||||||
defer os.Remove(tempFile.Name())
|
_ = tempFile.Close()
|
||||||
|
_ = os.Remove(tempFile.Name())
|
||||||
|
}()
|
||||||
// 初始化上传
|
// 初始化上传
|
||||||
state := GetState(account)
|
state := GetState(account)
|
||||||
|
|
||||||
@ -718,7 +719,7 @@ func (driver Cloud189) FastUpload(file *model.FileStream, parentFile *model.File
|
|||||||
for i := 1; i <= count; i++ {
|
for i := 1; i <= count; i++ {
|
||||||
uploadData := uploadUrls.UploadUrls[fmt.Sprint("partNumber_", i)]
|
uploadData := uploadUrls.UploadUrls[fmt.Sprint("partNumber_", i)]
|
||||||
req, _ := http.NewRequest(http.MethodPut, uploadData.RequestURL, io.NewSectionReader(tempFile, int64(i-1)*DEFAULT, DEFAULT))
|
req, _ := http.NewRequest(http.MethodPut, uploadData.RequestURL, io.NewSectionReader(tempFile, int64(i-1)*DEFAULT, DEFAULT))
|
||||||
req.Header.Del("User-Agent")
|
req.Header.Set("User-Agent", "")
|
||||||
for k, v := range ParseHttpHeader(uploadData.RequestHeader) {
|
for k, v := range ParseHttpHeader(uploadData.RequestHeader) {
|
||||||
req.Header.Set(k, v)
|
req.Header.Set(k, v)
|
||||||
}
|
}
|
||||||
@ -756,8 +757,10 @@ func (driver Cloud189) uploadFamily(file *model.FileStream, parentFile *model.Fi
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer tempFile.Close()
|
defer func() {
|
||||||
defer os.Remove(tempFile.Name())
|
_ = tempFile.Close()
|
||||||
|
_ = os.Remove(tempFile.Name())
|
||||||
|
}()
|
||||||
|
|
||||||
fileMd5 := md5.New()
|
fileMd5 := md5.New()
|
||||||
if _, err = io.Copy(io.MultiWriter(fileMd5, tempFile), file); err != nil {
|
if _, err = io.Copy(io.MultiWriter(fileMd5, tempFile), file); err != nil {
|
||||||
@ -805,8 +808,10 @@ func (driver Cloud189) uploadPerson(file *model.FileStream, parentFile *model.Fi
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer tempFile.Close()
|
defer func() {
|
||||||
defer os.Remove(tempFile.Name())
|
_ = tempFile.Close()
|
||||||
|
_ = os.Remove(tempFile.Name())
|
||||||
|
}()
|
||||||
|
|
||||||
fileMd5 := md5.New()
|
fileMd5 := md5.New()
|
||||||
if _, err = io.Copy(io.MultiWriter(fileMd5, tempFile), file); err != nil {
|
if _, err = io.Copy(io.MultiWriter(fileMd5, tempFile), file); err != nil {
|
||||||
|
@ -467,8 +467,10 @@ func (driver AliDrive) Upload(file *model.FileStream, account *model.Account) er
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer tempFile.Close()
|
defer func() {
|
||||||
defer os.Remove(tempFile.Name())
|
_ = tempFile.Close()
|
||||||
|
_ = os.Remove(tempFile.Name())
|
||||||
|
}()
|
||||||
|
|
||||||
delete(reqBody, "pre_hash")
|
delete(reqBody, "pre_hash")
|
||||||
h := sha1.New()
|
h := sha1.New()
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"github.com/Xhofe/alist/model"
|
"github.com/Xhofe/alist/model"
|
||||||
"github.com/Xhofe/alist/utils"
|
"github.com/Xhofe/alist/utils"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func KeyCache(path string, account *model.Account) string {
|
func KeyCache(path string, account *model.Account) string {
|
||||||
@ -15,6 +16,9 @@ func KeyCache(path string, account *model.Account) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SaveSearchFiles[T model.ISearchFile](key string, obj []T) {
|
func SaveSearchFiles[T model.ISearchFile](key string, obj []T) {
|
||||||
|
if strings.Contains(key, ".balance") {
|
||||||
|
return
|
||||||
|
}
|
||||||
err := model.DeleteSearchFilesByPath(key)
|
err := model.DeleteSearchFilesByPath(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln("failed create search files", err)
|
log.Errorln("failed create search files", err)
|
||||||
|
@ -195,7 +195,7 @@ func (driver SFTP) Delete(path string, account *model.Account) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return client.Remove(utils.Join(account.RootFolder, path))
|
return client.remove(utils.Join(account.RootFolder, path))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver SFTP) Upload(file *model.FileStream, account *model.Account) error {
|
func (driver SFTP) Upload(file *model.FileStream, account *model.Account) error {
|
||||||
|
@ -49,7 +49,7 @@ func (client *Client) Files(remotePath string) ([]os.FileInfo, error) {
|
|||||||
return client.ReadDir(remotePath)
|
return client.ReadDir(remotePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *Client) Remove(remotePath string) error {
|
func (client *Client) remove(remotePath string) error {
|
||||||
f, err := client.Stat(remotePath)
|
f, err := client.Stat(remotePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
|
@ -363,8 +363,10 @@ func (driver XunLeiCloud) Upload(file *model.FileStream, account *model.Account)
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer tempFile.Close()
|
defer func() {
|
||||||
defer os.Remove(tempFile.Name())
|
_ = tempFile.Close()
|
||||||
|
_ = os.Remove(tempFile.Name())
|
||||||
|
}()
|
||||||
|
|
||||||
gcid, err := getGcid(io.TeeReader(file, tempFile), int64(file.Size))
|
gcid, err := getGcid(io.TeeReader(file, tempFile), int64(file.Size))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -26,7 +26,7 @@ func Proxy(w http.ResponseWriter, r *http.Request, link *base.Link, file *model.
|
|||||||
_ = link.Data.Close()
|
_ = link.Data.Close()
|
||||||
}()
|
}()
|
||||||
w.Header().Set("Content-Type", "application/octet-stream")
|
w.Header().Set("Content-Type", "application/octet-stream")
|
||||||
w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename=%s`, file.Name))
|
w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"; filename*=UTF-8''%s`, file.Name, url.QueryEscape(file.Name)))
|
||||||
w.Header().Set("Content-Length", strconv.FormatInt(file.Size, 10))
|
w.Header().Set("Content-Length", strconv.FormatInt(file.Size, 10))
|
||||||
if link.Header != nil {
|
if link.Header != nil {
|
||||||
for h, val := range link.Header {
|
for h, val := range link.Header {
|
||||||
@ -57,7 +57,7 @@ func Proxy(w http.ResponseWriter, r *http.Request, link *base.Link, file *model.
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename=%s`, url.QueryEscape(file.Name)))
|
w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"; filename*=UTF-8''%s`, file.Name, url.QueryEscape(file.Name)))
|
||||||
http.ServeContent(w, r, file.Name, fileStat.ModTime(), f)
|
http.ServeContent(w, r, file.Name, fileStat.ModTime(), f)
|
||||||
return nil
|
return nil
|
||||||
} else {
|
} else {
|
||||||
|
@ -50,7 +50,7 @@ func Static(r *gin.Engine) {
|
|||||||
c.Status(200)
|
c.Status(200)
|
||||||
if strings.HasPrefix(c.Request.URL.Path, "/@manage") {
|
if strings.HasPrefix(c.Request.URL.Path, "/@manage") {
|
||||||
_, _ = c.Writer.WriteString(conf.ManageHtml)
|
_, _ = c.Writer.WriteString(conf.ManageHtml)
|
||||||
} else if strings.HasPrefix(c.Request.URL.Path, "/debug/pprof") {
|
} else if strings.HasPrefix(c.Request.URL.Path, "/debug/pprof") && conf.Debug {
|
||||||
pprof.Index(c.Writer, c.Request)
|
pprof.Index(c.Writer, c.Request)
|
||||||
} else {
|
} else {
|
||||||
_, _ = c.Writer.WriteString(conf.IndexHtml)
|
_, _ = c.Writer.WriteString(conf.IndexHtml)
|
||||||
|
Reference in New Issue
Block a user