mirror of
https://github.com/drakkan/sftpgo.git
synced 2024-11-25 17:10:28 +00:00
azblob: fix SAS URL with embedded container name
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
parent
e7866047aa
commit
97d5680d1e
2 changed files with 7 additions and 6 deletions
|
@ -107,23 +107,24 @@ func NewAzBlobFs(connectionID, localTempDir, mountPath string, config AzBlobFsCo
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fs, fmt.Errorf("invalid SAS URL: %w", err)
|
return fs, fmt.Errorf("invalid SAS URL: %w", err)
|
||||||
}
|
}
|
||||||
|
svc, err := azblob.NewServiceClientWithNoCredential(fs.config.SASURL.GetPayload(), clientOptions)
|
||||||
|
if err != nil {
|
||||||
|
return fs, fmt.Errorf("invalid credentials: %v", err)
|
||||||
|
}
|
||||||
if parts.ContainerName != "" {
|
if parts.ContainerName != "" {
|
||||||
if fs.config.Container != "" && fs.config.Container != parts.ContainerName {
|
if fs.config.Container != "" && fs.config.Container != parts.ContainerName {
|
||||||
return fs, fmt.Errorf("container name in SAS URL %#v and container provided %#v do not match",
|
return fs, fmt.Errorf("container name in SAS URL %#v and container provided %#v do not match",
|
||||||
parts.ContainerName, fs.config.Container)
|
parts.ContainerName, fs.config.Container)
|
||||||
}
|
}
|
||||||
fs.config.Container = parts.ContainerName
|
fs.config.Container = parts.ContainerName
|
||||||
|
fs.containerClient, err = svc.NewContainerClient("")
|
||||||
} else {
|
} else {
|
||||||
if fs.config.Container == "" {
|
if fs.config.Container == "" {
|
||||||
return fs, errors.New("container is required with this SAS URL")
|
return fs, errors.New("container is required with this SAS URL")
|
||||||
}
|
}
|
||||||
}
|
fs.containerClient, err = svc.NewContainerClient(fs.config.Container)
|
||||||
svc, err := azblob.NewServiceClientWithNoCredential(fs.config.SASURL.GetPayload(), clientOptions)
|
|
||||||
if err != nil {
|
|
||||||
return fs, fmt.Errorf("invalid credentials: %v", err)
|
|
||||||
}
|
}
|
||||||
fs.hasContainerAccess = false
|
fs.hasContainerAccess = false
|
||||||
fs.containerClient, err = svc.NewContainerClient(fs.config.Container)
|
|
||||||
return fs, err
|
return fs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ func (fs *CryptFs) Create(name string, flag int) (File, *PipeWriter, func(), err
|
||||||
if flag == 0 {
|
if flag == 0 {
|
||||||
f, err = os.Create(name)
|
f, err = os.Create(name)
|
||||||
} else {
|
} else {
|
||||||
f, err = os.OpenFile(name, flag, os.ModePerm)
|
f, err = os.OpenFile(name, flag, 0666)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
|
|
Loading…
Reference in a new issue