galaxy_fds_sdk_golang

package module
v0.0.0-...-9e3140f Latest Latest
Warning

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

Go to latest
Published: May 16, 2016 License: Apache-2.0 Imports: 14 Imported by: 0

README

galaxy-fds-sdk-golang

Golang SDK for Xiaomi File Data Storage.

install

go get github.com/pyinx/galaxy-fds-sdk-golang

#example

package main

import (
	"fmt"
	"github.com/pyinx/galaxy-fds-sdk-golang"
)

func main() {
	c := galaxy_fds_sdk_golang.NewFDSClient("YOUR_APP_KEY", "YOUR_APP_SECRET")
	fmt.Println(c.Create_Bucket("test-testaaaaaaaaaa"))
	fmt.Println(c.Delete_Bucket("test-testaaaaaaaaaa"))
	c.List_Bucket()
	fmt.Println(c.Is_Bucket_Exists("test-testaaaaaa"))
	fmt.Println(c.Is_Object_Exists("test-testaaaaaa", "a.jpg"))
	content := c.Get_Object("test-testaaaaaa", "2.txt", 0, 100)
	fmt.Println(content)
	c.List_Object("test-testaaaaaa")
	c.Post_Object("test-testaaaaaa", "abcdefgssss", 300) // cache-control:300
	c.Put_Object("test-testaaaaaa", "1.txt", "abcdefg", 300)
	fmt.Println(c.Delete_Object("test-testaaaaaa", "2.txt"))
	fmt.Println(c.Rename_Object("test-testaaaaaa", "1.txt", "2.txt"))
	// Set_Public最后一个参数表示是否需要关闭CDN预取,如无特殊需要建议设成true
	// 放回两个值: 第一个是setpublic是否成功,第二个是cdn预取是否成功,默认为true
	fmt.Println(c.Set_Public("test-testaaaaaa", "2.txt", true))
	fmt.Println(c.Refresh_Object("test-testaaaaaa", "2.txt"))
}

Documentation

Index

Constants

View Source
const (
	DEFAULT_FDS_SERVICE_BASE_URI       = "http://files.fds.api.xiaomi.com/"
	DEFAULT_FDS_SERVICE_BASE_URI_HTTPS = "https://files.fds.api.xiaomi.com/"
	DEFAULT_CDN_SERVICE_URI            = "http://cdn.fds.api.xiaomi.com/"
	USER_DEFINED_METADATA_PREFIX       = "x-xiaomi-meta-"
	DELIMITER                          = "/"
)
View Source
const (
	PERMISSION_READ         = "READ"
	PERMISSION_WRITE        = "WRITE"
	PERMISSION_FULL_CONTROL = "FULL_CONTROL"
	PERMISSION_USER         = "USER"
	PERMISSION_GROUP        = "GROUP"
)

permission

Variables

View Source
var ALL_USERS = map[string]string{"id": "ALL_USERS"}
View Source
var AUTHENTICATED_USERS = map[string]string{"id": "AUTHENTICATED_USERS"}
View Source
var PRE_DEFINED_METADATA = []string{"cache-control",
	"content-encoding",
	"content-length",
	"content-md5",
	"content-type",
}

Functions

func Signature

func Signature(app_key, app_secret, method, u, content_md5, content_type string) (string, string)

Types

type FDSAuth

type FDSAuth struct {
	Url          string
	Method       string
	Data         string
	Content_Md5  string
	Content_Type string
	Headers      map[string]string
}

type FDSClient

type FDSClient struct {
	App_key    string
	App_secret string
}

func NEWFDSClient

func NEWFDSClient(App_key, App_secret string) *FDSClient

func (*FDSClient) Auth

func (c *FDSClient) Auth(auth FDSAuth) (*http.Response, error)

func (*FDSClient) Create_Bucket

func (c *FDSClient) Create_Bucket(bucketname string) (bool, error)

func (*FDSClient) Delete_Bucket

func (c *FDSClient) Delete_Bucket(bucketname string) (bool, error)

func (*FDSClient) Delete_Object

func (c *FDSClient) Delete_Object(bucketname, objectname string) (bool, error)

func (*FDSClient) Get_Object

func (c *FDSClient) Get_Object(bucketname, objectname string, postion, size int) (string, error)

func (*FDSClient) Is_Bucket_Exists

func (c *FDSClient) Is_Bucket_Exists(bucketname string) (bool, error)

func (*FDSClient) Is_Object_Exists

func (c *FDSClient) Is_Object_Exists(bucketname, objectname string) (bool, error)

func (*FDSClient) List_Bucket

func (c *FDSClient) List_Bucket() ([]string, error)

func (*FDSClient) List_Object

func (c *FDSClient) List_Object(bucketname string) ([]string, error)

prefix需要改进

func (*FDSClient) Post_Object

func (c *FDSClient) Post_Object(bucketname, data, filetype string, cachecontrol int) (string, error)

v1类型

func (*FDSClient) Prefetch_Object

func (c *FDSClient) Prefetch_Object(bucketname, objectname string) (bool, error)

func (*FDSClient) Put_Object

func (c *FDSClient) Put_Object(bucketname, objectname, data, filetype string, cachecontrol int) (bool, error)

v2类型 自定义文件名 如果object已存在,将会覆盖

func (*FDSClient) Refresh_Object

func (c *FDSClient) Refresh_Object(bucketname, objectname string) (bool, error)

func (*FDSClient) Rename_Object

func (c *FDSClient) Rename_Object(bucketname, src_objectname, dst_objectname string) (bool, error)

func (*FDSClient) Set_Object_Acl

func (c *FDSClient) Set_Object_Acl(bucketname, objectname string, acl map[string]interface{}) (bool, error)

func (*FDSClient) Set_Public

func (c *FDSClient) Set_Public(bucketname, objectname string, disable_prefetch bool) (bool, error)

Jump to

Keyboard shortcuts

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