feat: fileshare custom password support

pull/2493/head
wintbit 2025-06-15 19:18:20 +08:00
parent 40644f5234
commit a1f92d572e
3 changed files with 7 additions and 1 deletions

View File

@ -111,6 +111,7 @@ type (
CreateShareArgs struct {
ExistedShareID int
IsPrivate bool
Password string
RemainDownloads int
Expire *time.Time
ShareView bool

View File

@ -259,8 +259,11 @@ func (l *manager) CreateOrUpdateShare(ctx context.Context, path *fs.URI, args *C
password := ""
if args.IsPrivate {
password = args.Password
if password == "" {
password = util.RandString(8, util.RandomLowerCases)
}
}
props := &types.ShareProps{
ShareView: args.ShareView,

View File

@ -20,6 +20,7 @@ type (
ShareCreateService struct {
Uri string `json:"uri" binding:"required"`
IsPrivate bool `json:"is_private"`
Password string `json:"password"`
RemainDownloads int `json:"downloads"`
Expire int `json:"expire"`
ShareView bool `json:"share_view"`
@ -52,6 +53,7 @@ func (service *ShareCreateService) Upsert(c *gin.Context, existed int) (string,
share, err := m.CreateOrUpdateShare(c, uri, &manager.CreateShareArgs{
IsPrivate: service.IsPrivate,
Password: service.Password,
RemainDownloads: service.RemainDownloads,
Expire: expires,
ExistedShareID: existed,