Documentation
¶
Index ¶
- Constants
- func GetExportMimeType(sourceMimeType, format string) (string, error)
- func GetFileExtension(format string) string
- func GetSupportedExportFormats(sourceMimeType string) []string
- func GetTypeName(mimeType string) string
- func IsGoogleWorkspaceFile(mimeType string) bool
- type Client
- type DriveClientInterface
- type File
Constants ¶
const ( MimeTypeFolder = "application/vnd.google-apps.folder" MimeTypeDocument = "application/vnd.google-apps.document" MimeTypeSpreadsheet = "application/vnd.google-apps.spreadsheet" MimeTypePresentation = "application/vnd.google-apps.presentation" MimeTypeDrawing = "application/vnd.google-apps.drawing" MimeTypeForm = "application/vnd.google-apps.form" MimeTypeSite = "application/vnd.google-apps.site" MimeTypeShortcut = "application/vnd.google-apps.shortcut" )
MIME type constants for Google Workspace files
Variables ¶
This section is empty.
Functions ¶
func GetExportMimeType ¶ added in v1.0.23
GetExportMimeType returns the MIME type for exporting a Google Workspace file to the specified format. Returns an error if the format is not supported.
func GetFileExtension ¶ added in v1.0.23
GetFileExtension returns the appropriate file extension for a format
func GetSupportedExportFormats ¶ added in v1.0.23
GetSupportedExportFormats returns the supported export formats for a Google Workspace file type
func GetTypeName ¶
GetTypeName returns a human-readable name for a MIME type
func IsGoogleWorkspaceFile ¶
IsGoogleWorkspaceFile returns true if the MIME type is a Google Workspace file that requires export rather than direct download
Types ¶
type Client ¶
Client wraps the Google Drive API service
func (*Client) DownloadFile ¶ added in v1.0.23
DownloadFile downloads a regular (non-Google Workspace) file
func (*Client) ExportFile ¶ added in v1.0.23
ExportFile exports a Google Workspace file to the specified MIME type
type DriveClientInterface ¶
type DriveClientInterface interface {
// ListFiles returns files matching the query
ListFiles(query string, pageSize int64) ([]*File, error)
// GetFile retrieves a single file by ID
GetFile(fileID string) (*File, error)
// DownloadFile downloads a regular (non-Google Workspace) file
DownloadFile(fileID string) ([]byte, error)
// ExportFile exports a Google Workspace file to the specified MIME type
ExportFile(fileID string, mimeType string) ([]byte, error)
}
DriveClientInterface defines the interface for Drive client operations. This enables unit testing through mock implementations.
type File ¶
type File struct {
ID string `json:"id"`
Name string `json:"name"`
MimeType string `json:"mimeType"`
Size int64 `json:"size,omitempty"`
CreatedTime time.Time `json:"createdTime,omitempty"`
ModifiedTime time.Time `json:"modifiedTime,omitempty"`
Parents []string `json:"parents,omitempty"`
Owners []string `json:"owners,omitempty"`
WebViewLink string `json:"webViewLink,omitempty"`
}
File represents a Google Drive file with simplified fields for JSON output