Skip to content

Commit

Permalink
fix: Throw error if Context is http Context (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
hwbrzzl authored Feb 8, 2025
1 parent 8a06ee5 commit 12ea811
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
.idea
.DS_Store
5 changes: 5 additions & 0 deletions oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/gookit/color"
"github.com/goravel/framework/contracts/config"
"github.com/goravel/framework/contracts/filesystem"
contractshttp "github.com/goravel/framework/contracts/http"
"github.com/goravel/framework/support/carbon"
"github.com/goravel/framework/support/str"
)
Expand Down Expand Up @@ -344,6 +345,10 @@ func (r *Oss) TemporaryUrl(file string, t time.Time) (string, error) {
}

func (r *Oss) WithContext(ctx context.Context) filesystem.Driver {
if httpCtx, ok := ctx.(contractshttp.Context); ok {
ctx = httpCtx.Context()
}

driver, err := NewOss(ctx, r.config, r.disk)
if err != nil {
color.Redf("init %s error: %+v\n", r.disk, err)
Expand Down

0 comments on commit 12ea811

Please sign in to comment.