-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
124 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 3 additions & 7 deletions
10
book-store-management-backend/component/uploadprovider/provider.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
package uploadprovider | ||
|
||
import ( | ||
"book-store-management-backend/common" | ||
"context" | ||
) | ||
import "book-store-management-backend/common" | ||
|
||
type UploadProvider interface { | ||
UploadImage(ctx context.Context, data []byte, dst string) (*common.Image, error) | ||
SaveFileUploaded(ctx context.Context, data []byte, dst string) (*common.Image, error) | ||
type UploadStaticProvider interface { | ||
UploadImage(data []byte, path string) (common.Image, error) | ||
} |
6 changes: 6 additions & 0 deletions
6
book-store-management-backend/component/uploadprovider/provider_firebasestorage.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
book-store-management-backend/component/uploadprovider/provider_static.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package uploadprovider | ||
|
||
import ( | ||
"book-store-management-backend/common" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
type staticUploadProvider struct { | ||
staticPath string | ||
} | ||
|
||
func NewStaticUploadProvider(staticPath string) *staticUploadProvider { | ||
return &staticUploadProvider{ | ||
staticPath: staticPath, | ||
} | ||
} | ||
|
||
func (provider *staticUploadProvider) UploadImage(data []byte, filename string) (common.Image, error) { | ||
image := common.Image{ | ||
CloudName: "local", | ||
Url: "/" + filename, | ||
} | ||
|
||
// create file | ||
fullPath := filepath.Join(provider.staticPath, filename) | ||
file, err := os.Create(fullPath) | ||
if err != nil { | ||
return common.Image{}, err // Return the error if file creation fails | ||
} | ||
defer file.Close() | ||
|
||
// write data to file | ||
if _, err := file.Write(data); err != nil { | ||
return common.Image{}, err | ||
} | ||
|
||
return image, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
mkdir -p ./storage | ||
chmod 777 -R ./storage | ||
gin --appPort 8080 --immediate | ||
chmod 777 -R ./storage | ||
gin --appPort 8080 --immediate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
book-store-management-backend/module/upload/uploadbiz/upload_file.go
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
book-store-management-backend/private/firebase-auth-key.json
This file was deleted.
Oops, something went wrong.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters