mirror of https://github.com/grafana/grafana
Merge pull request #10059 from FunkyM/local-image-store
Add support for internal image storepull/8689/merge
commit
184e7046df
@ -0,0 +1,22 @@ |
||||
package imguploader |
||||
|
||||
import ( |
||||
"context" |
||||
"path" |
||||
"path/filepath" |
||||
|
||||
"github.com/grafana/grafana/pkg/setting" |
||||
) |
||||
|
||||
type LocalUploader struct { |
||||
} |
||||
|
||||
func (u *LocalUploader) Upload(ctx context.Context, imageOnDiskPath string) (string, error) { |
||||
filename := filepath.Base(imageOnDiskPath) |
||||
image_url := setting.ToAbsUrl(path.Join("public/img/attachments", filename)) |
||||
return image_url, nil |
||||
} |
||||
|
||||
func NewLocalImageUploader() (*LocalUploader, error) { |
||||
return &LocalUploader{}, nil |
||||
} |
@ -0,0 +1,18 @@ |
||||
package imguploader |
||||
|
||||
import ( |
||||
"context" |
||||
"testing" |
||||
|
||||
. "github.com/smartystreets/goconvey/convey" |
||||
) |
||||
|
||||
func TestUploadToLocal(t *testing.T) { |
||||
Convey("[Integration test] for external_image_store.local", t, func() { |
||||
localUploader, _ := NewLocalImageUploader() |
||||
path, err := localUploader.Upload(context.Background(), "../../../public/img/logo_transparent_400x.png") |
||||
|
||||
So(err, ShouldBeNil) |
||||
So(path, ShouldContainSubstring, "/public/img/attachments") |
||||
}) |
||||
} |
Loading…
Reference in new issue