filemanager

package
v0.0.0-...-c2c2e9c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const KIND_FILE = "File"

Variables

This section is empty.

Functions

func CreateJSONResponse

func CreateJSONResponse(c context.Context, images []File, cursor string) ([]byte, error)

ファイルの一覧をクライアントに返すため、FileのスライスをJSONシリアライズします。

func FileListViewHandler

func FileListViewHandler(rw http.ResponseWriter, req *http.Request)

func GetParentKey

func GetParentKey(c context.Context) *datastore.Key

func GetServingURL

func GetServingURL(c context.Context, filename string) (servingURL *url.URL, err error)

GetServingURL gets URL to serve GCS file to users.

func NewFileKey

func NewFileKey(c context.Context) (*datastore.Key, error)

func Store

func Store(c context.Context, data []byte, fileName, mimeType, bucketName string) (absFilename string, err error)

Store binary data to GCS

func StoreImage

func StoreImage(c context.Context, key *datastore.Key, servingURL, fileName, gcsPath string) error

アップロードされた画像のメタデータをDSに保存します。

func UploadHandler

func UploadHandler(rw http.ResponseWriter, req *http.Request)

Types

type File

type File struct {
	ServingURL   string `datastore:",noindex" json:"url"`
	FileName     string `datastore:",noindex" json:"filename"`
	GCSPath      string `datastore:",noindex" json:"-"` // gcs.go:Store()の戻り値absFilename
	Type         Type
	ThumbnailURL string `datastore:"-" json:"thumbnail"`
	ds.Meta
}

func GetImages

func GetImages(c context.Context, cursorStr string) ([]File, string, error)

画像のメタデータ一覧をDSから取得します。 TODO: 表示する画像数を絞る必要がないなら、Cursor必要ないかも。

type ResponseData

type ResponseData struct {
	Files  []File `json:"files"`
	Cursor string `json:"cursor"`
}

type Type

type Type string
const (
	FILE  Type = "file"
	IMAGE      = "image"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL