wopi

package
v3.0.0-...-3edb00a Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: GPL-3.0 Imports: 16 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DiscoverResponseCacheKey = "wopi_discover"
	DiscoverRefreshDuration  = 24 * 3600 // 24 hrs
)
View Source
const (
	SessionCachePrefix  = "wopi_session_"
	AccessTokenQuery    = "access_token"
	OverwriteHeader     = wopiHeaderPrefix + "Override"
	ServerErrorHeader   = wopiHeaderPrefix + "ServerError"
	RenameRequestHeader = wopiHeaderPrefix + "RequestedName"

	MethodLock        = "LOCK"
	MethodUnlock      = "UNLOCK"
	MethodRefreshLock = "REFRESH_LOCK"
	MethodRename      = "RENAME_FILE"
)

Variables

View Source
var (
	ActionPreview         = ActonType("embedview")
	ActionPreviewFallback = ActonType("view")
	ActionEdit            = ActonType("edit")
)
View Source
var (
	ErrActionNotSupported = errors.New("action not supported by current wopi endpoint")

	Default   Client
	DefaultMu sync.Mutex
)

Functions

func Init

func Init()

Init initializes a new global WOPI client.

Types

type Action

type Action struct {
	Text      string `xml:",chardata"`
	Name      string `xml:"name,attr"`
	Ext       string `xml:"ext,attr"`
	Default   string `xml:"default,attr"`
	Urlsrc    string `xml:"urlsrc,attr"`
	Requires  string `xml:"requires,attr"`
	Targetext string `xml:"targetext,attr"`
	Progid    string `xml:"progid,attr"`
	UseParent string `xml:"useParent,attr"`
	Newprogid string `xml:"newprogid,attr"`
	Newext    string `xml:"newext,attr"`
}

type ActonType

type ActonType string

type Client

type Client interface {
	// NewSession creates a new document session with access token.
	NewSession(uid uint, file *model.File, action ActonType) (*Session, error)
	// AvailableExts returns a list of file extensions that are supported by WOPI.
	AvailableExts() []string
}

func NewClient

func NewClient(endpoint string, cache cache.Driver, http request.Client) (Client, error)

type Session

type Session struct {
	AccessToken    string
	AccessTokenTTL int64
	ActionURL      *url.URL
}

type SessionCache

type SessionCache struct {
	AccessToken string
	FileID      uint
	UserID      uint
	Action      ActonType
}

type WopiDiscovery

type WopiDiscovery struct {
	XMLName xml.Name `xml:"wopi-discovery"`
	Text    string   `xml:",chardata"`
	NetZone struct {
		Text string `xml:",chardata"`
		Name string `xml:"name,attr"`
		App  []struct {
			Text                 string   `xml:",chardata"`
			Name                 string   `xml:"name,attr"`
			FavIconUrl           string   `xml:"favIconUrl,attr"`
			BootstrapperUrl      string   `xml:"bootstrapperUrl,attr"`
			AppBootstrapperUrl   string   `xml:"appBootstrapperUrl,attr"`
			ApplicationBaseUrl   string   `xml:"applicationBaseUrl,attr"`
			StaticResourceOrigin string   `xml:"staticResourceOrigin,attr"`
			CheckLicense         string   `xml:"checkLicense,attr"`
			Action               []Action `xml:"action"`
		} `xml:"app"`
	} `xml:"net-zone"`
	ProofKey struct {
		Text        string `xml:",chardata"`
		Oldvalue    string `xml:"oldvalue,attr"`
		Oldmodulus  string `xml:"oldmodulus,attr"`
		Oldexponent string `xml:"oldexponent,attr"`
		Value       string `xml:"value,attr"`
		Modulus     string `xml:"modulus,attr"`
		Exponent    string `xml:"exponent,attr"`
	} `xml:"proof-key"`
}

Response content from discovery endpoint.

Jump to

Keyboard shortcuts

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