示例代码
最近更新时间:2023-07-25
环境说明:本文件夹包含在边缘存储 文件展示,删除文件,删除目录,上传文件功能的示例代码。
go 示例
go 开发版本: go1.10.3go 示例代码下载
###函数参数说明
func (api *ApiSdk) FileList(uri string, pageno int, pagesize int) string {...}
- uri:目录名称,前面均不运行带“/”,如:“test/path1/dir”
- pageno: 要显示第几页的数据,pageno不能为0
- pagesize:每页要显示数据的最大条目数,当pagesize为0会查询全部的数据
func (api *ApiSdk) RmFile(uri []string) string {...}
func (api *ApiSdk) RmDir(uri []string) string {...}
func (api *ApiSdk) UploadFile(exipiretime, fp, uploadUri string) {...}
- exipiretime:期望上传文件在ESS存储中保存的过期时间
- fp:要上传文件的本地路径
- uploadUri:上传uri
###使用说明
- 进入go_demo/src目录
- 修改 main.go (1) 将生成Token对象中的AccessKey和SecretKey改为用户申请的ak和sk (2) 将生成ApiSdk对象中的Bucket修改为用户申请的bucket
- 运行
go run main.go
------list file test------
{"errno":0,"reason":"success","filelist":[{"name":"a","size":0,"create_time":"","isdir":1},{"name":"23","size":0,"create_time":"","isdir":1}]}
------remove file test------
{"errno":0,"reason":"Success"}
------remove directory test------
{"errno":0,"reason":"success"}
------upload file test------
{"errno":0, "errmsg":"OK"}
python 示例
python 开发版本: Python 2.7.5python 示例代码下载
###函数参数说明
def fileList(self, uri, pageno, pagesize)
- uri:目录名称,前面均不运行带“/”,如:“test/path1/dir”
- pageno: 要显示第几页的数据,pageno不能为0
- pagesize:每页要显示数据的最大条目数,当pagesize为0会查询全部的数据
def rmFile(self, uri)
def rmDir(self, uri)
def uploadFile(self, exipiretime, filePath, uploadUri)
- exipiretime:期望上传文件在ESS存储中保存的过期时间
- filePath:要上传文件的本地路径
- uploadUri:上传uri
###使用说明
- 进入python_demo目录
- 修改main.go文件 (1) 将生成Token对象中的accesskey和secretkey值改为用户申请的ak和sk (2) 将生成ApiSdk对象中的bucket值改为用户申请的bucket
- 运行
python main.py
------list file test------
{"errno":0,"reason":"success"}
------remove file test------
{"errno":0,"reason":"Success"}
------remove directory test------
{"errno":0,"reason":"success"}
------upload file test------
{"errno":0, "errmsg":"OK"}
php 示例
php 开发版本:php 7.0.30php 示例代码下载
###函数参数说明
function fileList($uri, $pageno, $pagesize){...}
- uri:目录名称,前面均不运行带“/”,如:“test/path1/dir”
- pageno: 要显示第几页的数据,pageno不能为0
- pagesize:每页要显示数据的最大条目数,当pagesize为0会查询全部的数据
function rmFile($uri) {...}
function rmDir($uri) {...}
function uploadFile(){...}
- 上传文件接口主要依赖生成UploadFile对象的参数: upload_uri、local_file_path、exipiretime
- exipiretime:期望上传文件在ESS存储中保存的过期时间
- local_file_path:要上传文件的本地路径
- upload_uri:上传uri
###使用说明
- 进入php_demo目录
- 修改main.php (1) 将变量ak、sk、bucket的值改为用户申请的ak、sk、bucket
- 运行
php main.php
--------- list file test ---------
{"errno":0,"reason":"success","filelist":[{"name":"a","size":0,"create_time":"","isdir":1},{"name":"23","size":0,"create_time":"","isdir":1}]}
--------- remove file test ----------
{"errno":0,"reason":"Success"}
--------- remove directory test -------------
{"errno":0,"reason":"success"}
--------- upload file test ----------
{"errno":0, "errmsg":"OK"}