Beispiel #1
0
        public string UpLoadFile()
        {
            #region params
            string bucketName=string.Empty;
            string key = string.Empty;
            string localFile = string.Empty;
            string bigkey = string.Empty;
            string bigFile = string.Empty;
            string DOMAINName = string.Empty;
            Client conn;
            RSService rs;
            #endregion params

            if (context.Request["key"] == null)
            { return string.Concat(new[] { jsonCallback, "({\"errorMessage\":\"参数不正确\"})" }); }
            else
            { key = context.Request["key"]; }
            //万一能取到全地址
            if (key.IndexOf('\\') > 0)
            {
                key = key.Substring(key.LastIndexOf('\\'));
            }
            //公有秘钥
            Config.ACCESS_KEY = "b4Tb1AzHnH0xHLqAeLBMg9MGAw2IBaDgqo47zuUu";
            //私有秘钥
            Config.SECRET_KEY = "ZVD00fr92pv-0-o8dTk2N7lxxs1g0s54SYCsbhEi";
            bucketName = "sean1194";
            //放置的域名
            DOMAINName = bucketName + ".qiniudn.com";

            //获得签名认证
            conn = new DigestAuthClient();
            // 签名认证完成后,即可使用该认证来新建资源表
            rs = new RSService(conn, bucketName);
            //这句话最好在上传下载之前执行一遍,恐drop了之后会更改
            CallRet callRet = rs.MkBucket();

            string entryUrl = QBox.Util.Base64UrlSafe.Encode(bucketName + ":" + key);
            var authPolicy = new AuthPolicy(bucketName, 3600);
            string upToken = authPolicy.MakeAuthTokenString();

            string ret = "{"
                    + "bucketName : "
                    + bucketName
                    + ",key: "
                    + key
                    + ",DOMAINName : "
                    + DOMAINName
                    + ",upToken: "
                    + upToken
                    + ",entryUrl : "
                    + entryUrl
                    + "}";
            return ret;
        }
Beispiel #2
0
        public static void Main()
        {
            Config.ACCESS_KEY = "<Please apply your access key>";
            Config.SECRET_KEY = "<Dont send your secret key to anyone>";

            bucketName = "csharpbucket";
            DEMO_DOMAIN = "csharpbucket.dn.qbox.me";
            localFile = "Resource/gogopher.jpg";
            key = "gogopher.jpg";

            conn = new DigestAuthClient();
            rs = new RSService(conn, bucketName);
            imageOp = new ImageOp(conn);

            MkBucket();
            RSClientPutFile();
            Get();
            Stat();
            Publish();
            UnPublish();
            Delete();
            Drop();

            MkBucket();
            RSPutFile();
            Publish();
            ImageOps();

            Console.ReadLine();
        }
Beispiel #3
0
        public static void Main()
        {
            Config.ACCESS_KEY = "<Please apply your access key>";
            Config.SECRET_KEY = "<Dont send your secret key to anyone>";

            bucketName = "yourbucket";
            DEMO_DOMAIN = bucketName + ".qiniudn.com";
            key = "gogopher.jpg";
            localFile = "Resource/gogopher.jpg";
            bigkey = key;
            bigFile = localFile;

            conn = new DigestAuthClient();
            rs = new RSService(conn, bucketName);

            MkBucket();
            RSClientPutFile();
            RSClientPutFileWithCRC32();
            Get(key);
            ResumablePutFile();
            Stat(bigkey);
            Delete(key);
            Drop();

            MkBucket();
            ImageOps();

            MakeDownloadToken();

            Console.ReadLine();
        }