对象存储

  • 对象存储 > 实用工具 > 单行式操作

    单行式操作

    最近更新时间: 2022-11-29 15:51:33

    针对 process 功能提供的单行命令模式,为需要对单个资源执行一次操作提供方便,程序生命周期只有一次,从输入行指定 process 及 data 参数,直接执行并输出结果。【此功能不需要数据源配置】

    使用方式

    单行模式指令参数为 -s/–single/-line=<data-line>

    在指定 process 的情况下加上 -s 或者 --single 则表示使用单行模式,会直接执行 process 操作,因此必须包含该 process 所需的最少参数(兼容各 process 提供的参数用法,具体可参见 process 的文档)包括要处理的 data 参数,如 key 或 url 等。
    说明:
    1、-d 为新版 qsuits 的 account 用法,参考:账号设置
    2、 直接使用 qsuits 命令是执行代理器用法,参考:命令行执行器

    1 删除空间资源 delete

    ➜ ~ qsuits -s -d -process=delete-bucket=temp -key=10.mp4
    10.mp4	
    

    2 复制资源到指定空间 copy

    ➜ ~ qsuits -s -d -process=copy -bucket=temp -to-bucket=temp -key=10.mp4
    10.mp4	10.mp4	
    

    3 移动资源到指定空间 move

    ➜ ~ qsuits -s -d -process=move -bucket=temp -to-bucket=temp -key=10.mp4
    10.mp4	10.mp4	
    

    4 对资源进行重命名 rename

    ➜ ~ qsuits -s -d -process=rename -bucket=temp -add-prefix=1 -key=10.mp4
    10.mp4	10.mp4	
    

    5 查询资源的元信息 stat

    ➜ ~ qsuits -s -d -process=stat -bucket=temp -key=10.mp4
    10.mp4	FhbkdU00yYIPg13-Qu6jZzLVYqvT	524167	2019-06-04T19:09:35.897355100	video/mp4	0	1
    

    6 修改资源的存储类型(低频/标准)type

    ➜ ~ qsuits -s -d -process=type -bucket=temp -type=1 -key=10.mp4
    10.mp4	1	
    

    7 修改资源的状态(启用/禁用)status

    ➜ ~ qsuits -s -d -process=status -bucket=temp -status=1 -key=10.mp4
    10.mp4	1	
    

    8 修改资源的生命周期 lifecycle

    ➜ ~ qsuits -s -d -process=lifecycle -bucket=temp -days=1 -key=10.mp4
    10.mp4	1	
    

    9 对镜像源空间进行资源更新 mirror

    ➜ ~ qsuits -s -d -process=mirror -to-bucket=temp -key=10.mp4
    Exception in thread "main" com.qiniu.common.QiniuException: https://iovip.qiniuio.com/prefetch/dGVtcDoxMC5tcDQ=  
    {ResponseInfo:com.qiniu.http.Response@365c30cc,status:478, reqId:vewAAAAqlUx1-qQV, xlog:X-Log, xvia:, adress:iovip.qiniuio.com/218.98.28.24:443, duration:0.000000 s, error:httpGet url failed: E502}  
    {"error":"httpGet url failed: E502"}
    	at com.qiniu.http.Client.send(Client.java:263)
    	at com.qiniu.http.Client.post(Client.java:193)
    	at com.qiniu.http.Client.post(Client.java:176)
    	at com.qiniu.storage.BucketManager.post(BucketManager.java:667)
    	at com.qiniu.storage.BucketManager.ioPost(BucketManager.java:652)
    	at com.qiniu.storage.BucketManager.prefetch(BucketManager.java:546)
    	at com.qiniu.process.qoss.MirrorFile.singleResult(MirrorFile.java:54)
    	at com.qiniu.process.qoss.MirrorFile.singleResult(MirrorFile.java:12)
    	at com.qiniu.process.Base.processLine(Base.java:256)
    	at com.qiniu.entry.EntryMain.main(EntryMain.java:35)
    

    10 异步抓取资源到指定空间 asyncfetch

    ➜ ~ qsuits -i -d -process=asyncfetch -to-bucket=temp -url=http://xxx.bkt.clouddn.com/10.mp4
    10.mp4	http://p3l1d5mx4.bkt.clouddn.com/10.mp4	200	{"id":"eyJ6b25lIjoiejAiLCJxdWV1ZSI6IlNJU1lQSFVTLUpPQlMtVjMiLCJwYXJ0X2lkIjoyMiwib2Zmc2V0IjoxMjM0OTk2NH0=","wait":3}
    

    11 查询资源的 qhash

    ➜ ~ qsuits -s -process=qhash -url=http://xxx.bkt.clouddn.com/10.mp4
    http://p3l1d5mx4.bkt.clouddn.com/10.mp4	{"hash":"dc7a26a67763b478f0b05ec38b769349","fsize":524167}
    

    12 查询空间资源的视频元信息 avinfo

    ➜ ~ qsuits -s -process=avinfo -url=http://xxx.bkt.clouddn.com/10.mp4
    http://p3l1d5mx4.bkt.clouddn.com/10.mp4	{"streams":[{"index":0,"codec_name":"h264","codec_long_name":"H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10","profile":"High","codec_type":"video","codec_time_base":"1/60","codec_tag_string":"avc1","codec_tag":"0x31637661","width":720,"height":486,"coded_width":720,"coded_height":496,"has_b_frames":2,"sample_aspect_ratio":"1:1","display_aspect_ratio":"40:27","pix_fmt":"yuv420p","level":30,"chroma_location":"left","refs":1,"is_avc":"true","nal_length_size":"4","r_frame_rate":"30/1","avg_frame_rate":"30/1","time_base":"1/15360","start_pts":0,"start_time":"0.000000","duration_ts":92160,"duration":"6.000000","bit_rate":"695088","bits_per_raw_sample":"8","nb_frames":"180","disposition":{"default":1,"dub":0,"original":0,"comment":0,"lyrics":0,"karaoke":0,"forced":0,"hearing_impaired":0,"visual_impaired":0,"clean_effects":0,"attached_pic":0,"timed_thumbnails":0},"tags":{"creation_time":"2011-09-15T17:31:45.000000Z","language":"eng","handler_name":"VideoHandler"}}],"format":{"nb_streams":1,"nb_programs":0,"format_name":"mov,mp4,m4a,3gp,3g2,mj2","format_long_name":"QuickTime / MOV","start_time":"0.000000","duration":"6.000000","size":"524167","bit_rate":"698889","probe_score":100,"tags":{"major_brand":"isom","minor_version":"512","compatible_brands":"isomiso2avc1mp41","creation_time":"2011-09-15T17:31:45.000000Z","encoder":"Lavf57.71.100"}}}
    

    13 根据 avinfo 生成转码指令 pfopcmd

    ➜ ~ qsuits -s -process=pfopcmd -scale="[999]" -cmd=avthumb/mp4 -saveas="temp:key.mp4" -key=test -avinfo="{\"streams\":[{\"index\":0,\"codec_name\":\"h264\",\"codec_long_name\":\"H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10\",\"profile\":\"Main\",\"codec_type\":\"video\",\"codec_time_base\":\"1/50\",\"codec_tag_string\":\"avc1\",\"codec_tag\":\"0x31637661\",\"width\":1920,\"height\":1080,\"coded_width\":1920,\"coded_height\":1088,\"has_b_frames\":2,\"pix_fmt\":\"yuv420p\",\"level\":40,\"chroma_location\":\"left\",\"refs\":1,\"is_avc\":\"true\",\"nal_length_size\":\"4\",\"r_frame_rate\":\"25/1\",\"avg_frame_rate\":\"25/1\",\"time_base\":\"1/12800\",\"start_pts\":0,\"start_time\":\"0.000000\",\"duration_ts\":2506240,\"duration\":\"195.800000\",\"bit_rate\":\"4829438\",\"bits_per_raw_sample\":\"8\",\"nb_frames\":\"4895\",\"disposition\":{\"default\":1,\"dub\":0,\"original\":0,\"comment\":0,\"lyrics\":0,\"karaoke\":0,\"forced\":0,\"hearing_impaired\":0,\"visual_impaired\":0,\"clean_effects\":0,\"attached_pic\":0,\"timed_thumbnails\":0},\"tags\":{\"language\":\"und\",\"handler_name\":\"VideoHandler\"}},{\"index\":1,\"codec_name\":\"aac\",\"codec_long_name\":\"AAC (Advanced Audio Coding)\",\"profile\":\"LC\",\"codec_type\":\"audio\",\"codec_time_base\":\"1/48000\",\"codec_tag_string\":\"mp4a\",\"codec_tag\":\"0x6134706d\",\"sample_fmt\":\"s16p\",\"sample_rate\":\"48000\",\"channels\":2,\"channel_layout\":\"stereo\",\"bits_per_sample\":0,\"r_frame_rate\":\"0/0\",\"avg_frame_rate\":\"0/0\",\"time_base\":\"1/48000\",\"start_pts\":0,\"start_time\":\"0.000000\",\"duration_ts\":9399264,\"duration\":\"195.818000\",\"bit_rate\":\"128006\",\"max_bit_rate\":\"128006\",\"nb_frames\":\"9181\",\"disposition\":{\"default\":1,\"dub\":0,\"original\":0,\"comment\":0,\"lyrics\":0,\"karaoke\":0,\"forced\":0,\"hearing_impaired\":0,\"visual_impaired\":0,\"clean_effects\":0,\"attached_pic\":0,\"timed_thumbnails\":0},\"tags\":{\"language\":\"und\",\"handler_name\":\"SoundHandler\"}}],\"format\":{\"nb_streams\":2,\"nb_programs\":0,\"format_name\":\"mov,mp4,m4a,3gp,3g2,mj2\",\"format_long_name\":\"QuickTime / MOV\",\"start_time\":\"0.000000\",\"duration\":\"195.852000\",\"size\":\"121481511\",\"bit_rate\":\"4962175\",\"probe_score\":100,\"tags\":{\"major_brand\":\"isom\",\"minor_version\":\"512\",\"compatible_brands\":\"isomiso2avc1mp41\",\"encoder\":\"Lavf56.18.101\"}}}"
    test	avthumb/mp4|saveas/dGVtcDprZXkubXA0 
    

    14 对空间资源执行 pfop 请求 pfop

    ➜ ~ qsuits -s -d -process=pfop -bucket=temp -key=110.mp4 -fops="avthumb/mp4|saveas/dGVtcDprZXkubXA0"
    Exception in thread "main" java.io.IOException: please set pipeline, if you don't want to use private pipeline, please set the force-public as true.
    	at com.qiniu.entry.QSuitsEntry.getPfop(QSuitsEntry.java:445)
    	at com.qiniu.entry.QSuitsEntry.whichNextProcessor(QSuitsEntry.java:326)
    	at com.qiniu.entry.EntryMain.main(EntryMain.java:32)
    ➜ ~ qsuits -s -d -process=pfop -bucket=temp -key=110.mp4 -fops="avthumb/mp4|saveas/dGVtcDprZXkubXA0" -force-public=true
    10.mp4	z0.5cf4e0b138b9f31ea670c97e
    

    15 查询 pfop 的结果 pfopresult

    ➜ ~ qsuits -s -process=pfopresult -id=z0.5cf6460238b9f31ea6d3d29d
    z0.5cf6460238b9f31ea6d3d29d	{"code":0,"desc":"The fop was completed successfully","id":"z0.5cf6460238b9f31ea6d3d29d","inputBucket":"temp","inputKey":"110.mp4","items":[{"cmd":"avthumb/mp4|saveas/dGVtcDprZXkubXA0","code":0,"desc":"The fop was completed successfully","hash":"FpBw7VMk5raxi-MG0ooVuPUSMNEs","key":"key.mp4","returnOld":0}],"pipeline":"0.default","reqid":"uxAAACmnPRWo96QV"}
    

    16 对私有空间资源进行签名 privateurl

    ➜ ~ qsuits -s -d -process=privateurl -url=http://xxx.bkt.clouddn.com/test.gif
    http://test.xxx.com/test.gif?e=1559650444&token=XgP9wnGCGGX8FlS7zxfOQcPev6pFUBo0T:OmxkuR3z60Vj9PUdhOjAph9KWYc=
    

    17 导出 m3u8 中的 ts 列表 exportts

    ➜ ~ qsuits -s -process=exportts -url=http://xxx.bkt.clouddn.com/csc-4.m3u8
    http://p3l28y6an.bkt.clouddn.com/room_02/csc000000	60.08sec
    http://p3l28y6an.bkt.clouddn.com/room_02/csc000001	60.0sec
    http://p3l28y6an.bkt.clouddn.com/room_02/csc000002	60.0sec
    http://p3l28y6an.bkt.clouddn.com/room_02/csc000003	60.0sec
    http://p3l28y6an.bkt.clouddn.com/room_02/csc000004	60.0sec
    http://p3l28y6an.bkt.clouddn.com/room_02/csc000005	60.0sec
    http://p3l28y6an.bkt.clouddn.com/room_02/csc000006	60.0sec
    http://p3l28y6an.bkt.clouddn.com/room_02/csc000007	60.0sec
    http://p3l28y6an.bkt.clouddn.com/room_02/csc000008	60.0sec
    http://p3l28y6an.bkt.clouddn.com/room_02/csc000009	7.8sec
    

    18 对图片类型资源进行内容审核 imagecensor

    ➜ ~ qsuits -d -s -process=imagecensor -url="http://xxx.bkt.clouddn.com/1568621317685_2561217040d45e3-ef50-400b-929a-11ac01cc745b.png?e=1883981319&token=Lix9HHSQrTTVYqLG3aaUvJPNB3uBoz9GtxCqMS5G:cv3i7pmLfq6oM_3Q-bXvrZkGYS8="  -scenes=ads -s
    http://xxx.com/1568621317685_2561217040d45e3-ef50-400b-929a-11ac01cc745b.png?e=1883981319&token=Lix9HHSQrTTVYqLG3aaUvJPNB3uBoz9GtxCqMS5G:cv3i7pmLfq6oM_3Q-bXvrZkGYS8=	{"code":200,"message":"OK","result":{"suggestion":"pass","scenes":{"ads":{"suggestion":"pass"}}}}
    

    19 对视频类型资源进行内容审核 videocensor

    ➜ ~ qsuits -d -s -process=videocensor -url="http://xxx.bkt.clouddn.com/-YVzTgC_I8zlDYIm8eCcPnA76pU=/ltSP7XPbPGviBNjXiZEHX7mpdm6o" -scenes=pulp
    http://xxx.bkt.clouddn.com/-YVzTgC_I8zlDYIm8eCcPnA76pU=/ltSP7XPbPGviBNjXiZEHX7mpdm6o	5d9c6fefbc499b000874793b
    

    20 查询视频审核结果 censorresult

    ➜ ~ qsuits -d -s -process=censorresult -id=5d9c6fefbc499b000874793b
    {"id":"5d9c6fefbc499b000874793b","vid":"","request":{"data":{"uri":"http://xxx.bkt.clouddn.com/-YVzTgC_I8zlDYIm8eCcPnA76pU=/ltSP7XPbPGviBNjXiZEHX7mpdm6o"},"params":{"sync":false,"scenes":["pulp"]}},"status":"DOING","created_at":"2019-10-08T19:15:59.943+08:00","updated_at":"2019-10-08T19:16:21.923+08:00","rescheduled_at":"2019-10-08T19:15:59.943+08:00"}
    

    21 通过 http 下载资源到本地 downloadfile

    ➜ ~ qsuits -d -s -process=download -url=http://xxx.bkt.clouddn.com/test.go -down-path=.
    test.go	http://xxx.bkt.clouddn.com/test.go	/Users/wubingheng/Downloads/test.go
    

    22 上传文件到七牛存储空间 uploadfile

    ➜ ~ qsuits -d -s -process=qupload -bucket=temp -filepath=test.py -key=test.py
    test.py	{"hash":"Fto5o-5ea0sNMlW_75VgGJCv2AcJ","key":"test.py"}
    

    23 修改文件的 mime

    ➜ ~ qsuits -d -s -process=mime -bucket=temp -key=test.py -mime=text/plain
    test.py	200
    

    24 修改文件的 metadata

    ➜ ~ qsuits -d -s -process=metadata -bucket=temp -key=test.py -meta.Cache-Control="public, max-age=3600"
    test.py	200
    

    25 CDN 预取和刷新 cdn

    ➜ ~ qsuits -d -s -url=http://devtools.qiniu.com/qsuits-8.3.12-jar-with-dependencies.jar -process=cdnprefetch
    http://devtools.qiniu.com/qsuits-8.3.12-jar-with-dependencies.jar	{"code":200,"error":"success","requestId":"5e0f9363d308f632d9ac7cd2","taskIds":{"http://devtools.qiniu.com/qsuits-8.3.12-jar-with-dependencies.jar":"5e0f9363d308f632d9ac7cd3"},"invalidUrls":null,"quotaDay":100,"surplusDay":89}
    ➜ ~ qsuits -d -s -url=http://devtools.qiniu.com/qsuits-8.3.12-jar-with-dependencies.jar -process=cdnrefresh
    http://devtools.qiniu.com/qsuits-8.3.12-jar-with-dependencies.jar	{"code":200,"error":"success","requestId":"5e0f94ba43d72330d2ac2d64","taskIds":{"http://devtools.qiniu.com/qsuits-8.3.12-jar-with-dependencies.jar":"5e0f94ba43d72330d2ac2d65"},"invalidUrls":null,"invalidDirs":null,"urlQuotaDay":100,"urlSurplusDay":89,"dirQuotaDay":100,"dirSurplusDay":100}
    
    以上内容是否对您有帮助?
  • Qvm free helper
    Close