Documentation ¶
Index ¶
- Constants
- Variables
- func AssembleDirectoryBucketName(id []byte) []byte
- func AssembleDirectoryFilePath(directory, name string) string
- func AssembleListPath(path string) string
- func AssembleRouterDirectoryFilePath(router, directory, name string) string
- func AssembleUrl(reqUrl string, data map[string]string) string
- func FormatSize(size uint64) string
- func GetFreePort() (int, error)
- func HttpRequestAuth(reqUrl, method string, data, headers map[string]string) ([]byte, error)
- type Auth
- func (a *Auth) GetAccessTokenWithAuthCode(code string) error
- func (a *Auth) GetAuthUrl() string
- func (a *Auth) Graph() *Graph
- func (a *Auth) HttpAuthRequest(w http.ResponseWriter, r *http.Request)
- func (a *Auth) HttpRedirectOneDrive(w http.ResponseWriter, r *http.Request)
- func (a *Auth) OpenAuthUrl()
- func (a *Auth) RefreshToken() error
- func (a *Auth) RunRedirectHttp(addr, router string) *http.Server
- func (a *Auth) WithToken(token *Token) *Auth
- type Config
- type DB
- type DriveFile
- type DriveFiles
- type DriveItemPreviewResp
- type DrivePathChildren
- type DrivePathChildrenResp
- type DrivePathResp
- type File
- type Folder
- type Graph
- func (g *Graph) GetDriveItemPreview(itemId string) (resp *DriveItemPreviewResp, err error)
- func (g *Graph) GetDrivePath(path string) (resp *DrivePathResp, err error)
- func (g *Graph) GetDrivePathChildren(path string) (resp *DrivePathChildrenResp, err error)
- func (g *Graph) GetDrivePathChildrenNextLink(nextLink string) (resp *DrivePathChildrenResp, err error)
- type OneDrive
- func (od *OneDrive) Cfg() Config
- func (od *OneDrive) CheckUpdate(path string) (bool, error)
- func (od *OneDrive) ClearRepository(path string) error
- func (od *OneDrive) GetFile(path string) (driveFile *DriveFile, driveFileChildren, driveFolderChildren []*DriveFile, ...)
- func (od *OneDrive) RefreshDownloadUrl(driveFile *DriveFile) error
- func (od *OneDrive) RefreshToken() error
- func (od *OneDrive) SyncRepository(path string) error
- type ParentReference
- type Repository
- type Token
Constants ¶
View Source
const ( MethodGET = "GET" MethodPOST = "POST" //https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=ea2b36f6-b8ad-40be-bc0f-e5e4a4a7d4fa&scope=files.readwrite offline_access&response_type=code&redirect_uri=http://localhost/onedrive-login GetAuthCodeUrl = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize" //?client_id={%s}&scope={%s}&response_type=code&redirect_uri={%s} GetOrRefreshAccessToken = "https://login.microsoftonline.com/common/oauth2/v2.0/token" )
View Source
const ( AuthId = "34b0b5a2-9df6-4f56-93f7-793ba1fd0858" AuthSecret = "p3zjb]3Ldkrii2Edk1?WGxY]xmwdyD]n" AuthScope = "files.readwrite offline_access" AuthRedirectAddr = "localhost:53841" AuthRouter = "/" )
View Source
const ( GraphUrl = "https://graph.microsoft.com/v1.0" DrivePathUrl = "/drives/me/root%s" DrivePathChildrenUrl = "/drives/me/root%s/children??orderby=name" DriveItemPreviewUrl = "/drives/me/items/%s/preview" DriveItemThumbnailsUrl = "/drives/me/items/%s/thumbnails" DriveItemThumbnailsContentUrl = "/drives/me/items/%s/thumbnails/%s/%s/content" DriveItemsTimeFormat = "2006-01-02T15:04:05Z" )
View Source
const ( KeyFilePrefix = "onedrive_file" KeyDirectoryPrefix = "onedrive_directory" )
View Source
const ( LocationShanghaiKey = "Asia/Shanghai" TimeToFormat = "2006-01-02 15:04:05" )
View Source
const ( B = 1 << (10 * iota) KB MB GB TB PB EB )
Variables ¶
View Source
var ( FileBucketName = zbolt.StringToBytes(KeyFilePrefix) DirectoryBucketName = AssembleDirectoryBucketName )
View Source
var (
LocationShanghai, _ = time.LoadLocation(LocationShanghaiKey)
)
Functions ¶
func AssembleRouterDirectoryFilePath ¶
Types ¶
type Auth ¶
type Auth struct { ClientID string `json:"client_id"` ClientSecret string `json:"client_secret"` Scope string `json:"scope"` RedirectUri string `json:"redirect_uri"` Token *Token `json:"token"` Ch chan interface{} `json:"ch"` }
func (*Auth) GetAccessTokenWithAuthCode ¶
func (*Auth) HttpAuthRequest ¶
func (a *Auth) HttpAuthRequest(w http.ResponseWriter, r *http.Request)
type Config ¶
type Config struct { RootPath string `json:"root_path"` TokenRefreshRate int64 `json:"token_cycle"` FileRefreshRate int64 `json:"file_cycle"` DownloadTimeout int64 `json:"download_timeout"` Token *Token `json:"token"` RootPathModified int64 `json:"root_path_modified"` }
func NewConfig ¶
func (Config) OneDriveConfig ¶
func (cfg Config) OneDriveConfig() config.OneDriveConfig
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
type DriveFile ¶
type DriveFile struct { Id string `json:"id"` Name string `json:"name"` Size uint64 `json:"size"` ModifiedTime int64 `json:"modifiedTime"` Path string `json:"path"` DownloadUrl string `json:"@microsoft.graph.downloadUrl"` MimeType string `json:"mimeType"` ChildCount uint64 `json:"childCount"` UpdateTime int64 `json:"updateTime"` }
func FilterFile ¶
type DriveFiles ¶
type DriveFiles []*DriveFile
func (DriveFiles) HandleRootPath ¶
func (ds DriveFiles) HandleRootPath(rootPath string) DriveFiles
type DrivePathChildren ¶
type DrivePathChildrenResp ¶
type DrivePathChildrenResp struct { NextLink string `json:"@odata.nextLink"` DrivePathResps []DrivePathResp `json:"value"` }
func (*DrivePathChildrenResp) Folders ¶
func (d *DrivePathChildrenResp) Folders() []string
func (DrivePathChildrenResp) ToDrivePathChildren ¶
func (d DrivePathChildrenResp) ToDrivePathChildren() *DrivePathChildren
type DrivePathResp ¶
type DrivePathResp struct { Id string `json:"id"` Name string `json:"name"` Size uint64 `json:"size"` LastModifiedDateTime string `json:"lastModifiedDateTime"` DownloadUrl string `json:"@microsoft.graph.downloadUrl"` ParentReference ParentReference `json:"parentReference"` Folder *Folder `json:"folder"` File *File `json:"file"` }
func (*DrivePathResp) ChildCount ¶
func (d *DrivePathResp) ChildCount() uint64
func (*DrivePathResp) FormatTime ¶
func (d *DrivePathResp) FormatTime(formatLocation, timeFromFormat string) int64
func (*DrivePathResp) MimeType ¶
func (d *DrivePathResp) MimeType() string
func (*DrivePathResp) Path ¶
func (d *DrivePathResp) Path() string
func (*DrivePathResp) ToDriveFile ¶
func (d *DrivePathResp) ToDriveFile() *DriveFile
type Graph ¶
type Graph struct {
AccessToken string `json:"access_token"`
}
func (*Graph) GetDriveItemPreview ¶
func (g *Graph) GetDriveItemPreview(itemId string) (resp *DriveItemPreviewResp, err error)
func (*Graph) GetDrivePath ¶
func (g *Graph) GetDrivePath(path string) (resp *DrivePathResp, err error)
func (*Graph) GetDrivePathChildren ¶
func (g *Graph) GetDrivePathChildren(path string) (resp *DrivePathChildrenResp, err error)
func (*Graph) GetDrivePathChildrenNextLink ¶
func (g *Graph) GetDrivePathChildrenNextLink(nextLink string) (resp *DrivePathChildrenResp, err error)
type OneDrive ¶
type OneDrive struct {
// contains filtered or unexported fields
}
func (*OneDrive) GetFile ¶
func (*OneDrive) RefreshDownloadUrl ¶
type ParentReference ¶
type Repository ¶
Click to show internal directories.
Click to hide internal directories.