drive

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
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 GetTypeName

func GetTypeName(mimeType string) string

GetTypeName returns a human-readable name for a MIME type

func IsGoogleWorkspaceFile

func IsGoogleWorkspaceFile(mimeType string) bool

IsGoogleWorkspaceFile returns true if the MIME type is a Google Workspace file that requires export rather than direct download

Types

type Client

type Client struct {
	Service *drive.Service
}

Client wraps the Google Drive API service

func NewClient

func NewClient(ctx context.Context) (*Client, error)

NewClient creates a new Drive client with OAuth2 authentication

func (*Client) GetFile

func (c *Client) GetFile(fileID string) (*File, error)

GetFile retrieves a single file by ID

func (*Client) ListFiles

func (c *Client) ListFiles(query string, pageSize int64) ([]*File, error)

ListFiles returns files matching the query

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)
}

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"`
	Shared       bool      `json:"shared"`
}

File represents a Google Drive file with simplified fields for JSON output

func ParseFile

func ParseFile(f *drive.File) *File

ParseFile converts a Google Drive API File to our simplified File struct

Jump to

Keyboard shortcuts

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