Skip to content

Instantly share code, notes, and snippets.

Stream API

特别说明

  • 最新功能体验可以将 API Host 改为 pili-lte.qiniuapi.com

新建流

请求包:

#!/bin/sh
INPUT_FILE="clock.flv";
if [ ! -f "$INPUT_FILE" ]; then
echo "clock.flv not found, start downloading...\n"
curl -o "clock.flv" "http://ykgroup.qiniudn.com/clock4.flv"
fi
#TELECOM
<script type="text/javascript">
// Not Required
var gSound = 'A background-music.mp3 URL';
var playsound = function()
{
var audio = new Audio();
audio.loop = true;
audio.src = gSound;
document.body.appendChild(audio);
audio.play();
require 'openssl'
require 'base64'
require 'uri'
def base64_url_encode(str)
Base64.encode64(str).tr("+/", "-_").gsub(/[\n\r]?/, "")
end
def digest(secret, bytes)
OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha1'), secret, bytes)
String key = IO.UNDEFINED_KEY; // 自动生成key, 也可指定key名
PutExtra extra = new PutExtra();
extra.checkCrc = PutExtra.AUTO_CRC32; // 可选, 上传校验crc32值
extra.params.put("x:arg", "val"); // 可选, 自定义参数, callback时可传递给AppServer
IO.putFile(this, uploadToken, key, uri, extra, new JSONObjectRet() {
@Override
public void onSuccess(JSONObject resp) {
// ...
}
conf.ACCESS_KEY = "YOUR_APP_ACCESS_KEY"
conf.SECRET_KEY = "YOUR_APP_SECRET_KEY"
putPolicy := rs.PutPolicy {
Scope, // 必须, 目标存储空间
ReturnUrl, // 可选, 指定上传成功后301跳转URL
ReturnBody, // 可选, 自定义客户端ResponseBody, 可用魔法变量求值
CallbackUrl, // 可选, 指定通知回调URL
CallbackBody, // 可选, 指定通知回调ResquestBody, 可使用魔法变量求值
PersistentOps, // 可选, 音视频等大文件上传异步预转指令集合
@why404
why404 / qiniu-autosync.sh
Last active December 11, 2015 05:48
qboxrsctl + inotify-tools 实现七牛云存储文件管理。 可监控指定目录,若发现新增/改动的文件可自动上传,若发现有文件删除可自动删除七牛云存储上对应的文件(不需要该功能可注释相关代码)。 工具下载 - qboxrsctl - <http://docs.qiniutek.com/v3/tools/qboxrsctl/> - inotify-tools - <https://github.com/rvoicilas/inotify-tools/wiki>
#!/bin/sh
# 此脚本可监控 Linux/Unix 上指定的文件夹,并将此文件夹内的新增或改动文件自动同步到七牛云存储,可设定同步删除。
# 1. 需先安装 inotify-tools - <https://github.com/rvoicilas/inotify-tools/wiki>
# 2. 然后下载 qboxrsctl - <http://docs.qiniutek.com/v3/tools/qboxrsctl/>
# 获取 ACCESS_KEY 和 SECRET_KEY 以及 BUCKET_NAME (空间名称) 请登录:<https://dev.qiniutek.com>
# 用法(反斜杠用于排版换行需要,实际情况下可忽略):
@why404
why404 / ObjectCompare.js
Created November 10, 2010 06:19
Compare two JavaScript objects
function isEqual(a,b)
{
var c = typeof(a);
var d = typeof(b);
if (c != d) return false;
if (c != "object") return a == b;
var m = 0, n = 0;
for (var e in a)
{
m += 1;
@why404
why404 / BoardTest.java
Created October 28, 2010 14:36
Write a program that randomly fills in 0s and 1s into an 8 x 8 checker board,prints the board to the dialog box, and reports the rows, columns, and diagonals (more than 2) with all 0s or 1s. Use a two-dimensional array to represent a checker board.
why404@404-ubuntu:~/code$ cat BoardTest.java
// Source Code for BoardTest.java
public class BoardTest
{
public static void main(String args[])
{
char[][] pic = new char[8][8];
for (int i = 0; i < 8; i++)