# 命令行工具(phar)

# 说明

新浪云存储命令行工具,基于PHP的phar实现。

# 依赖

  • PHP版本大于等于5.3.0
  • 安装curl扩展
  • 安装mbString扩展
  • 安装json扩展
  • 安装Phar扩展
  • 安装pcre扩展

CentOS下安装PHP

在CentOS环境下可以执行 yum install php php-* 快速安装PHP环境。

# 安装

  1. 下载 scs.phar (http://sdk.sinastorage.cn/scs.phar
  2. 给下载的文件加上可执行权限 chmod +x /path/to/scs.phar
  3. 执行php /path/to/scs.phar -h 或者 /path/to/scs.phar -h

以CentOS系统为例:

yum install yum install php php-*
yum install wget
mkdir -p /scs-phar/
cd /scs/phar/
wget http://sdk.sinastorage.cn/scs.phar
chmod +x scs.phar

# 使用示例

$ ./scs.phar -h

**************************
*     _____ _____ _____  *
*    / ___// ___// ___/  *
*   (__  )/ /__ (__  )   *
*  / ___/ \____/ ___/    *
*                        *
**************************

scs-cli-tool version 0.1.0


Usage:

 [options] COMMAND [parameters]


Options:

 -h, --help
    show this help message and exit
 -ck, --clear_keys
    Clear Access Key and Secret Key


Commands:

 Make bucket
    scs.phar mb scs://BUCKET
 Remove bucket
    scs.phar rb scs://BUCKET
 List objects or buckets
    scs.phar ls [scs://BUCKET[/PREFIX]]
 Get file from bucket
    scs.phar get scs://BUCKET/OBJECT LOCAL_FILE
 Put file into bucket
    scs.phar put FILE [FILE...] scs://BUCKET[/PREFIX]
 Delete file from bucket
    scs.phar del scs://BUCKET/OBJECT
 Get information about Files
    scs.phar info scs://BUCKET/OBJECT
 Copy object
    scs.phar cp scs://BUCKET1/OBJECT1 scs://BUCKET2[/OBJECT2]


$ ./scs.phar ls

total: 6

 2014-03-31 09:48:35       5694878  cloud8                        
 2014-04-09 11:49:21      19724702  cloud123                      
 2014-04-12 16:43:26             0  cloudside                     
 2014-04-14 10:55:10             0  sina-com-cn                   
 2014-04-16 21:49:38         63265  sdk                           
 2014-04-16 21:50:02             0  api     

$ ./scs.phar ls scs://cloud123

 2014-04-17 13:31:19       1011280  composer.phar          
 2014-04-16 22:22:19          2836  path/to/my/Diamond Heart.gif  
 2014-04-16 22:22:20          2793  path/to/my/Diamond Round.gif  
 2014-04-16 22:22:20          2204  path/to/my/Diamond Square.gif 
 2014-04-16 22:22:20          2789  path/to/my/Emerald Round.gif  
 2014-04-16 22:22:20          2205  path/to/my/Emerald Square.gif 
 2014-04-16 22:22:21          2785  path/to/my/Princess Heart.gif 
 2014-04-16 22:22:21          2792  path/to/my/Princess Round.gif 
 2014-04-16 22:22:21          2200  path/to/my/Princess Square.gif
 2014-04-16 22:22:21          2781  path/to/my/Ruby Heart.gif     
 2014-04-16 22:22:21          2734  path/to/my/Ruby Round.gif     
 ...