Skip to content

Commit 49acfbf

Browse files
ncwyuval-cloudinary
authored andcommitted
gofile: fix failed downloads on newly uploaded objects
The upload routine no longer returns a url to download the object. This fixes the problem by fetching it if necessary when we attempt to Open the object.
1 parent 4a3f28c commit 49acfbf

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

backend/gofile/gofile.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,13 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.Read
14691469
if o.id == "" {
14701470
return nil, errors.New("can't download - no id")
14711471
}
1472+
if o.url == "" {
1473+
// On upload an Object is returned with no url, so fetch it here if needed
1474+
err = o.readMetaData(ctx)
1475+
if err != nil {
1476+
return nil, fmt.Errorf("read metadata: %w", err)
1477+
}
1478+
}
14721479
fs.FixRangeOption(options, o.size)
14731480
var resp *http.Response
14741481
opts := rest.Opts{

0 commit comments

Comments
 (0)