Path + format

This commit is contained in:
Quentin 2021-11-20 09:53:05 +01:00
parent 514731cf4b
commit 4448577ec1
4 changed files with 33 additions and 22 deletions

View file

@ -46,7 +46,9 @@ type LdapError struct {
Username string
Err error
}
func (e *LdapError) Error() string { return "ldap error for " + e.Username + ": " + e.Err.Error() }
type LdapWrongPasswordError struct{ LdapError }
func LdapGetS3(c *Config, username, password string) (access_key, secret_key string, werr error) {

13
main.go
View file

@ -3,15 +3,15 @@ package main
import (
"context"
"fmt"
"git.deuxfleurs.fr/Deuxfleurs/bagage/s3"
"git.deuxfleurs.fr/Deuxfleurs/bagage/sftp"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
"golang.org/x/crypto/ssh"
"io"
"io/ioutil"
"net"
"git.deuxfleurs.fr/Deuxfleurs/bagage/sftp"
"git.deuxfleurs.fr/Deuxfleurs/bagage/s3"
"github.com/minio/minio-go/v7/pkg/credentials"
"github.com/minio/minio-go/v7"
"golang.org/x/crypto/ssh"
"log"
"net"
"net/http"
)
@ -36,6 +36,7 @@ type s3creds struct {
accessKey string
secretKey string
}
var keychain map[string]s3creds
func sshServer(dconfig *Config, done chan error) {

View file

@ -19,6 +19,7 @@ type S3File struct {
objw *io.PipeWriter
donew chan error
pos int64
eof bool
entries []fs.FileInfo
Path S3Path
}
@ -85,12 +86,19 @@ func (f *S3File) Read(p []byte) (n int, err error) {
}
func (f *S3File) ReadAt(p []byte, off int64) (n int, err error) {
if f.eof {
return 0, io.EOF
}
log.Printf("s3 ReadAt %v\n", off)
if err := f.loadObject(); err != nil {
return 0, err
}
return f.obj.ReadAt(p, off)
n, err = f.obj.ReadAt(p, off)
f.eof = err == io.EOF
return
}
func (f *S3File) WriteAt(p []byte, off int64) (n int, err error) {

View file

@ -1,8 +1,8 @@
package main
import (
"github.com/minio/minio-go/v7"
"git.deuxfleurs.fr/Deuxfleurs/bagage/s3"
"github.com/minio/minio-go/v7"
"golang.org/x/net/webdav"
"log"
"net/http"