summaryrefslogtreecommitdiff
path: root/internal/pipeline/put.go
diff options
context:
space:
mode:
authorNick White <git@njw.name>2021-08-02 10:45:53 +0100
committerNick White <git@njw.name>2021-08-02 10:45:53 +0100
commit4b7a4bd1b87d1dbba283e577aa03ce7e390d85d8 (patch)
treee5e7e55763cfbfd74e651a4ba5bea5b7394a93a9 /internal/pipeline/put.go
parent5310a5e77e945debdc7bd6f149ba87fab13902db (diff)
internal/pipeline: Add test (incomplete but working) for UploadImages
Diffstat (limited to 'internal/pipeline/put.go')
-rw-r--r--internal/pipeline/put.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/internal/pipeline/put.go b/internal/pipeline/put.go
index c08df53..26d581c 100644
--- a/internal/pipeline/put.go
+++ b/internal/pipeline/put.go
@@ -77,7 +77,10 @@ func DetectQueueType(dir string, conn Queuer) string {
}
}
-func UploadImages(dir string, bookname string, conn Uploader) error {
+// UploadImages uploads all files (except those which start with a ".")
+// from a directory (recursively) into a given storage id, prefixed with
+// the given bookname and a slash
+func UploadImages(dir string, bookname string, conn Uploader, storageId string) error {
walker := make(fileWalk)
go func() {
_ = filepath.Walk(dir, walker.Walk)
@@ -86,7 +89,7 @@ func UploadImages(dir string, bookname string, conn Uploader) error {
for path := range walker {
name := filepath.Base(path)
- err := conn.Upload(conn.WIPStorageId(), filepath.Join(bookname, name), path)
+ err := conn.Upload(storageId, bookname + "/" + name, path)
if err != nil {
return fmt.Errorf("Failed to upload %s: %v", path, err)
}