@@ -73,6 +73,11 @@ type Item struct {
73
73
isDir bool
74
74
}
75
75
76
+
// Replace any backslashes from windows to forward slashed
77
+
func forwardSlashes(target string) string {
78
+
return strings.ReplaceAll(target, fmt.Sprintf("%c", os.PathSeparator), "/")
79
+
}
80
+
76
81
type s3repo struct {
77
82
region string
78
83
bucket string
@@ -153,7 +158,7 @@ func (r *s3repo) Upload(path string, target string) error {
153
158
l.Infof("uploading %s to S3 bucket %s\n", path, r.bucket)
154
159
_, err = uploader.Upload(&s3manager.UploadInput{
155
160
Bucket: aws.String(r.bucket),
156
-
Key: aws.String(target),
161
+
Key: aws.String(forwardSlashes(target)),
157
162
Body: file,
158
163
})
159
164
@@ -174,7 +179,7 @@ func (r *s3repo) List(prefix string) ([]Item, error) {
174
179
for {
175
180
resp, err := svc.ListObjectsV2(&s3.ListObjectsV2Input{
176
181
Bucket: aws.String(r.bucket),
177
-
Prefix: aws.String(prefix),
182
+
Prefix: aws.String(forwardSlashes(prefix)),
178
183
ContinuationToken: contToken,
179
184
})
180
185
@@ -206,7 +211,7 @@ func (r *s3repo) Remove(path string) error {
206
211
207
212
_, err := svc.DeleteObject(&s3.DeleteObjectInput{
208
213
Bucket: aws.String(r.bucket),
209
-
Key: aws.String(path),
214
+
Key: aws.String(forwardSlashes(path)),
210
215
})
211
216
212
217
if err != nil {
@@ -548,7 +553,7 @@ func (r *gcsRepo) Upload(path string, target string) error {
548
553
}
549
554
defer file.Close()
550
555
551
-
obj := r.client.Bucket(r.bucket).Object(target).NewWriter(context.Background())
556
+
obj := r.client.Bucket(r.bucket).Object(forwardSlashes(target)).NewWriter(context.Background())
552
557
defer obj.Close()
553
558
554
559
l.Infof("uploading %s to GCS bucket %s\n", path, r.bucket)
@@ -564,7 +569,7 @@ func (r *gcsRepo) Upload(path string, target string) error {
564
569
func (r *gcsRepo) List(prefix string) (items []Item, rerr error) {
565
570
items = make([]Item, 0)
566
571
567
-
it := r.client.Bucket(r.bucket).Objects(context.Background(), &storage.Query{Prefix: prefix})
572
+
it := r.client.Bucket(r.bucket).Objects(context.Background(), &storage.Query{Prefix: forwardSlashes(prefix)})
568
573
for {
569
574
attrs, err := it.Next()
570
575
if err == iterator.Done {
@@ -587,7 +592,7 @@ func (r *gcsRepo) List(prefix string) (items []Item, rerr error) {
587
592
}
588
593
589
594
func (r *gcsRepo) Remove(path string) error {
590
-
if err := r.client.Bucket(r.bucket).Object(path).Delete(context.Background()); err != nil {
595
+
if err := r.client.Bucket(r.bucket).Object(forwardSlashes(path)).Delete(context.Background()); err != nil {
591
596
return fmt.Errorf("could not remove %s from GCS bucket %s: %w", path, r.bucket, err)
592
597
}
593
598
@@ -654,7 +659,7 @@ func (r *azRepo) Upload(path string, target string) error {
654
659
}
655
660
defer file.Close()
656
661
657
-
blob := r.client.NewBlockBlobClient(target)
662
+
blob := r.client.NewBlockBlobClient(forwardSlashes(target))
658
663
659
664
l.Infof("uploading %s to Azure container %s\n", path, r.container)
660
665
_, err = blob.UploadFileToBlockBlob(context.Background(), file, azblob.HighLevelUploadToBlockBlobOption{})
@@ -666,8 +671,9 @@ func (r *azRepo) Upload(path string, target string) error {
666
671
}
667
672
668
673
func (r *azRepo) List(prefix string) ([]Item, error) {
674
+
p := forwardSlashes(prefix)
669
675
pager := r.client.ListBlobsFlat(&azblob.ContainerListBlobFlatSegmentOptions{
670
-
Prefix: &prefix,
676
+
Prefix: &p,
671
677
})
672
678
673
679
files := make([]Item, 0)
@@ -692,7 +698,7 @@ func (r *azRepo) List(prefix string) ([]Item, error) {
692
698
}
693
699
694
700
func (r *azRepo) Remove(path string) error {
695
-
blob := r.client.NewBlockBlobClient(path)
701
+
blob := r.client.NewBlockBlobClient(forwardSlashes(path))
696
702
697
703
if _, err := blob.Delete(context.Background(), nil); err != nil {
698
704
return fmt.Errorf("could not remove blob from Azure container %s: %w", r.container, err)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4