Git Product home page Git Product logo

filemgr's Introduction

Instructions

ufile-gosdk进行简单封装。

文件操作

NewClient

func NewClient(namespace, key string, fileHost, regions ...string) (*Client, error)
  • namespace:命名空间,需要提前注册,测试为:nstest_1;
  • key:命名空间的token,测试为:*;
  • fileHost:文件服务地址,测试环境为:"http://192.168.152.186:8000/filemgr";
  • region:区域,这个参数不传或传入空字符串,会使用默认值。

Upload

func (c *Client) Upload(file string) (err error)
  • file:待上传的本地文件名。

Download

func (c *Client) Download(path, file string) (err error)
  • path:指定下载目录;
  • file:要下载的远程文件名。

List

func (c *Client) List(file ...string) (flist []FileInfo, err error)
  • file:需要获取文件的文件名或文件前缀,没有参数表示获取全部;
  • flist:获取的文件信息列表。
    • FName string 文件名
    • FSize int 文件大小
    • MTime string 修改时间
    • NSpace string 所属命名空间

Delete

func (c *Client) Delete(file string) (err error)
  • file:待删除的远程文件名。

示例代码

import "fielmgr"

// ...

    client, _ := filemgr.NewClient(namespace, token, region)

    switch operation {
    case "upload":
        client.Upload(fileName)
    case "download":
        client.Download(path, fileName)
    case "list":
        client.List(fileName)
    case "delete":
        client.Delete(fileName)
    default:
        fmt.Println("[ERR] Pls use correct operation! Such as \"upload, download, list, delete etc\". ")
        return
    }
// ...

filemgr's People

Contributors

aaronize avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.