box

package module
v1.0.3-0...-d252cc2 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2018 License: MIT Imports: 6 Imported by: 0

README

Coverage Status Go Report Card Build Status Documentation

QSC BOX SDK

V1 is a demo project for gotten.

V2 is released.

Usage

This package supports upload/download functions of single file.

type (
	Service struct {
		Upload      func(param *UploadParam) (gotten.Response, error) `method:"POST" path:"add_item"`
		Change      func(param *ChangeParam) (gotten.Response, error) `method:"POST" path:"change_item"`
		Stat        func(param *TokenParam) (gotten.Response, error)  `path:"issec/{token}"`              // resp: YES / NO<SP>
		Verify      func(param *SecParam) (gotten.Response, error)    `path:"verify/{token}/{sec_token}"` // resp: Y / N
		Download    func(param *TokenParam) (gotten.Response, error)  `path:"get/{token}"`
		DownloadSec func(param *SecParam) (gotten.Response, error)    `path:"get/{token}/{sec_token}"` // fail: html, no Content-Disposition
	}
)

Get service singleton by GetService()

resp, err := box.GetService().Upload(&box.UploadParam{File: gotten.FilePath("testAssets/avatar.jpg")})
if err == nil {
    var result box.UploadResult
    err = resp.Unmarshal(&result)	
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeParam

type ChangeParam struct {
	NewToken   string `type:"form"`
	Jiami      string `type:"form"`
	OldToken   string `type:"form" require:"true"`
	SecureId   string `type:"form" require:"true"`
	TokenSec   string `type:"form"`
	OldSec     string `type:"form"`
	Expiration int    `type:"form" require:"true"`
}

change

type ChangeResult

type ChangeResult struct {
	Message  string
	NewToken string
	Status   int // 0: Success; 1: fail
	Url      string
}

type SecParam

type SecParam struct {
	Token    string `type:"path"`
	SecToken string `type:"path"`
}

verify security token

type Service

type Service struct {
	Upload      func(param *UploadParam) (gotten.Response, error) `method:"POST" path:"add_item"`
	Change      func(param *ChangeParam) (gotten.Response, error) `method:"POST" path:"change_item"`
	Stat        func(param *TokenParam) (gotten.Response, error)  `path:"issec/{token}"`              // resp: YES / NO<SP>
	Verify      func(param *SecParam) (gotten.Response, error)    `path:"verify/{token}/{sec_token}"` // resp: Y / N
	Download    func(param *TokenParam) (gotten.Response, error)  `path:"get/{token}"`
	DownloadSec func(param *SecParam) (gotten.Response, error)    `path:"get/{token}/{sec_token}"` // fail: html, no Content-Disposition
}

func GetService

func GetService() *Service

GetService is a getter to get service singleton

type TokenParam

type TokenParam struct {
	Token string `type:"path"`
}

get status

type UploadParam

type UploadParam struct {
	PhpSession string          `type:"part" key:"PHP_SESSION_UPLOAD_PROGRESS" default:"qscbox"`
	Filecount  int             `type:"part" default:"1"`
	File       gotten.FilePath `type:"part" require:"true"`
	Callback   string          `type:"part" default:"handleUploadCallback"`
	IsIe9      int             `type:"part" default:"0"`
}

Upload

type UploadResult

type UploadResult struct {
	Data struct {
		Error      string
		Expiration int
		Filename   string
		Secret     string `json:"secret"`
		SecureId   string `json:"secure_id"`
		Token      string
	}
	Err        int // 0: SUCCESS; -1: Fail
	Expiration int
	Msg        string
}

Jump to

Keyboard shortcuts

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