Documentation
¶
Index ¶
- Variables
- func GetUserSession(headers http.Header) map[string]any
- func Version() string
- type APIError
- func BadDataError(err error, publicMessage string) *APIError
- func FailedToInitializeMetadataError(err error) *APIError
- func FileTooBigError(filename string, size, maxSize int) *APIError
- func FileTooSmallError(filename string, size, minSize int) *APIError
- func ForbiddenError(err error, publicMessage string) *APIError
- func InternalServerError(err error) *APIError
- func NewAPIError(statusCode int, publicMessage string, err error, data map[string]interface{}) *APIError
- func WrongMetadataFormatError(err error) *APIError
- type Antivirus
- type BucketMetadata
- type ContentStorage
- type Controller
- func (ctrl *Controller) DeleteBrokenMetadata(ctx *gin.Context)
- func (ctrl *Controller) DeleteFile(ctx *gin.Context)
- func (ctrl *Controller) DeleteOrphans(ctx *gin.Context)
- func (ctrl *Controller) GetFile(ctx *gin.Context)
- func (ctrl *Controller) GetFileInformation(ctx *gin.Context)
- func (ctrl *Controller) GetFilePresignedURL(ctx *gin.Context)
- func (ctrl *Controller) GetFileWithPresignedURL(ctx *gin.Context)
- func (ctrl *Controller) Health(ctx *gin.Context)
- func (ctrl *Controller) ListBrokenMetadata(ctx *gin.Context)
- func (ctrl *Controller) ListNotUploaded(ctx *gin.Context)
- func (ctrl *Controller) ListOrphans(ctx *gin.Context)
- func (ctrl *Controller) OpenAPI(ctx *gin.Context)
- func (ctrl *Controller) SetupRouter(trustedProxies []string, apiRootPrefix string, corsOrigins []string, ...) (*gin.Engine, error)
- func (ctrl *Controller) UpdateFile(ctx *gin.Context)
- func (ctrl *Controller) UploadFile(ctx *gin.Context)
- func (ctrl *Controller) Version(ctx *gin.Context)
- type ErrorResponse
- type FakeReadCloserWrapper
- type File
- type FileMetadata
- type FileResponse
- type FileSummary
- type GetFilePresignedURLRequest
- type GetFilePresignedURLResponse
- type GetFileResponse
- type GetFileWithPresignedURLRequest
- type ListBrokenMetadataResponse
- type ListOrphansResponse
- type MetadataStorage
- type UpdateFileResponse
- type UploadFileResponse
- type VersionResponse
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrMultipartFormFileNotFound = &APIError{ http.StatusBadRequest, "file[] not found in Multipart form", errors.New("file[] not found in Multipart form"), nil, } ErrMultipartFileWrong = &APIError{ http.StatusBadRequest, "wrong file data in multipart form, one needs to be specified", errors.New("wrong file data in multipart form, one needs to be specified"), nil, } ErrWrongDate = &APIError{ http.StatusBadRequest, "couldn't parse date", errors.New("couldn't parse date"), nil, } ErrMetadataLength = &APIError{ http.StatusBadRequest, "file metadata length doesn't match number of files in request", errors.New("file metadata length doesn't match number of files in request"), nil, } ErrBucketNotFound = &APIError{ http.StatusNotFound, "bucket not found", errors.New("bucket not found"), nil, } ErrFileNotFound = &APIError{ http.StatusNotFound, "file not found", errors.New("file not found"), nil, } ErrFileNotUploaded = &APIError{ http.StatusForbidden, "file not uploaded", errors.New("file not uploaded"), nil, } )
Functions ¶
Types ¶
type APIError ¶
type APIError struct {
// contains filtered or unexported fields
}
func BadDataError ¶
func FileTooBigError ¶
func FileTooSmallError ¶
func ForbiddenError ¶
func InternalServerError ¶
func NewAPIError ¶ added in v0.1.1
func (*APIError) ExtendError ¶
func (*APIError) GetDataString ¶ added in v0.4.0
func (*APIError) PublicResponse ¶
func (a *APIError) PublicResponse() *ErrorResponse
func (*APIError) StatusCode ¶
type BucketMetadata ¶
type ContentStorage ¶
type ContentStorage interface { PutFile( ctx context.Context, content io.ReadSeeker, filepath, contentType string, ) (string, *APIError) GetFile(ctx context.Context, filepath string, headers http.Header) (*File, *APIError) CreatePresignedURL( ctx context.Context, filepath string, expire time.Duration, ) (string, *APIError) GetFileWithPresignedURL( ctx context.Context, filepath, signature string, headers http.Header, ) (*File, *APIError) DeleteFile(ctx context.Context, filepath string) *APIError ListFiles(ctx context.Context) ([]string, *APIError) }
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
func New ¶
func New( publicURL string, apiRootPrefix string, hasuraAdminSecret string, metadataStorage MetadataStorage, contentStorage ContentStorage, imageTransformer *image.Transformer, av Antivirus, logger *logrus.Logger, ) *Controller
func (*Controller) DeleteBrokenMetadata ¶
func (ctrl *Controller) DeleteBrokenMetadata(ctx *gin.Context)
func (*Controller) DeleteFile ¶
func (ctrl *Controller) DeleteFile(ctx *gin.Context)
func (*Controller) DeleteOrphans ¶
func (ctrl *Controller) DeleteOrphans(ctx *gin.Context)
func (*Controller) GetFile ¶
func (ctrl *Controller) GetFile(ctx *gin.Context)
func (*Controller) GetFileInformation ¶
func (ctrl *Controller) GetFileInformation(ctx *gin.Context)
func (*Controller) GetFilePresignedURL ¶
func (ctrl *Controller) GetFilePresignedURL(ctx *gin.Context)
func (*Controller) GetFileWithPresignedURL ¶ added in v0.1.1
func (ctrl *Controller) GetFileWithPresignedURL(ctx *gin.Context)
func (*Controller) Health ¶
func (ctrl *Controller) Health(ctx *gin.Context)
func (*Controller) ListBrokenMetadata ¶
func (ctrl *Controller) ListBrokenMetadata(ctx *gin.Context)
func (*Controller) ListNotUploaded ¶
func (ctrl *Controller) ListNotUploaded(ctx *gin.Context)
func (*Controller) ListOrphans ¶
func (ctrl *Controller) ListOrphans(ctx *gin.Context)
func (*Controller) OpenAPI ¶
func (ctrl *Controller) OpenAPI(ctx *gin.Context)
func (*Controller) SetupRouter ¶
func (ctrl *Controller) SetupRouter( trustedProxies []string, apiRootPrefix string, corsOrigins []string, corsAllowCredentials bool, middleware ...gin.HandlerFunc, ) (*gin.Engine, error)
func (*Controller) UpdateFile ¶
func (ctrl *Controller) UpdateFile(ctx *gin.Context)
func (*Controller) UploadFile ¶
func (ctrl *Controller) UploadFile(ctx *gin.Context)
func (*Controller) Version ¶
func (ctrl *Controller) Version(ctx *gin.Context)
type ErrorResponse ¶
type ErrorResponse struct { Message string `json:"message"` Data map[string]interface{} `json:"data,omitempty"` }
Used to standardized the output of the handers' response.
type FakeReadCloserWrapper ¶
func NewP ¶
func NewP(b []byte) *FakeReadCloserWrapper
func (*FakeReadCloserWrapper) Close ¶
func (p *FakeReadCloserWrapper) Close() error
type FileMetadata ¶
type FileMetadata struct { ID string `json:"id"` Name string `json:"name"` Size int64 `json:"size"` BucketID string `json:"bucketId"` ETag string `json:"etag"` CreatedAt string `json:"createdAt"` UpdatedAt string `json:"updatedAt"` IsUploaded bool `json:"isUploaded"` MimeType string `json:"mimeType"` UploadedByUserID string `json:"uploadedByUserId"` Metadata map[string]any `json:"metadata"` }
type FileResponse ¶ added in v0.1.1
type FileResponse struct {
// contains filtered or unexported fields
}
func NewFileResponse ¶ added in v0.1.1
func (*FileResponse) Write ¶ added in v0.1.1
func (r *FileResponse) Write(ctx *gin.Context)
type FileSummary ¶
type GetFilePresignedURLRequest ¶
type GetFilePresignedURLRequest struct {
FileID string
}
type GetFilePresignedURLResponse ¶
type GetFilePresignedURLResponse struct { Error *ErrorResponse `json:"error,omitempty"` URL string `json:"url,omitempty"` Expiration int `json:"expiration,omitempty"` }
type GetFileResponse ¶
type GetFileResponse struct {
Error *ErrorResponse `json:"error"`
}
Only used if the request fails.
type GetFileWithPresignedURLRequest ¶ added in v0.1.1
type GetFileWithPresignedURLRequest struct { Expires int // contains filtered or unexported fields }
type ListBrokenMetadataResponse ¶
type ListBrokenMetadataResponse struct {
Metadata []FileSummary `json:"metadata"`
}
type ListOrphansResponse ¶
type ListOrphansResponse struct {
Files []string `json:"files"`
}
type MetadataStorage ¶
type MetadataStorage interface { GetBucketByID(ctx context.Context, id string, headers http.Header) (BucketMetadata, *APIError) GetFileByID(ctx context.Context, id string, headers http.Header) (FileMetadata, *APIError) InitializeFile( ctx context.Context, id, name string, size int64, bucketID, mimeType string, headers http.Header, ) *APIError PopulateMetadata( ctx context.Context, id, name string, size int64, bucketID, etag string, IsUploaded bool, mimeType string, metadata map[string]any, headers http.Header) (FileMetadata, *APIError, ) SetIsUploaded( ctx context.Context, fileID string, isUploaded bool, headers http.Header, ) *APIError DeleteFileByID(ctx context.Context, fileID string, headers http.Header) *APIError ListFiles(ctx context.Context, headers http.Header) ([]FileSummary, *APIError) InsertVirus( ctx context.Context, fileID, filename, virus string, userSession map[string]any, headers http.Header, ) *APIError }
type UpdateFileResponse ¶
type UpdateFileResponse struct { *FileMetadata Error *ErrorResponse `json:"error,omitempty"` }
type UploadFileResponse ¶
type UploadFileResponse struct { ProcessedFiles []FileMetadata `json:"processedFiles,omitempty"` Error *ErrorResponse `json:"error,omitempty"` }
this type is used to ensure we respond consistently no matter the case.
type VersionResponse ¶
type VersionResponse struct {
BuildVersion string `json:"buildVersion"`
}
Source Files
¶
- controller.go
- delete_broken_metadata.go
- delete_file.go
- delete_orphans.go
- errors.go
- get_file.go
- get_file_information.go
- get_file_presigned_url.go
- get_file_with_presigned_url.go
- list_broken_metadata.go
- list_not_uploaded.go
- list_orphans.go
- openapi.go
- response.go
- update_file.go
- upload_file.go
- user_session.go
- version.go
Click to show internal directories.
Click to hide internal directories.