am trying to fetch all the images in the folder I uploaded to storj test bucket but am unable to show the shared image in the browser as a read-only
below is the code showing the implementation
func (s *storjFileStorageSvc) ListItemFiles(user int64, itemID int32) ([]string, error) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
folder := fmt.Sprintf("%v/%v/", user, itemID)
iterator := s.project.ListObjects(ctx, s.config.Storj.BucketName, &uplink.ListObjectsOptions{
Prefix: folder,
Recursive: true,
})
var shareableLinks []string
for iterator.Next() {
object := iterator.Item()
// Restrict the permissions to only allow read access to the specific object
permission := uplink.ReadOnlyPermission()
shared := uplink.SharePrefix{Bucket: s.config.Storj.BucketName, Prefix: folder}
restrictedAccess, err := s.access.Share(permission, shared)
if err != nil {
return nil, err
}
serializedAccess, err := restrictedAccess.Serialize()
if err != nil {
return nil, err
}
link := fmt.Sprintf("%s/%s/%s", s.config.Storj.ShareEndpoint, serializedAccess, object.Key)
shareableLinks = append(shareableLinks, link)
}
if err := iterator.Err(); err != nil {
return nil, err
}
return shareableLinks, nil
}