Exemplo n.º 1
0
        /// <summary>
        /// 生成上传Token
        /// </summary>
        /// <returns></returns>
        public string Token(Mac mac = null)
        {
            if (mac == null)
            {
                mac = new Mac(Config.ACCESS_KEY, Config.Encoding.GetBytes(Config.SECRET_KEY));
            }
            string flag = QiniuJsonHelper.JsonEncode(this);

            return(mac.SignWithData(Config.Encoding.GetBytes(flag)));
        }
Exemplo n.º 2
0
        private async Task <BlkputRet> Mkblock(Client client, byte[] firstChunk, int blkSize)
        {
            string url = string.Format("{0}/mkblk/{1}", Config.UP_HOST, blkSize);

            CallRet callRet = await client.CallWithBinary(url, new Windows.Web.Http.Headers.HttpMediaTypeHeaderValue("application/octet-stream"), new MemoryStream(firstChunk, 0, blkSize), blkSize);

            if (callRet.OK)
            {
                return(QiniuJsonHelper.ToObject <BlkputRet>(callRet.Response));
            }
            return(null);
        }
Exemplo n.º 3
0
        private BlkputRet Mkblock(Client client, byte[] firstChunk, int blkSize)
        {
            string url = string.Format("{0}/mkblk/{1}", Config.UP_HOST, blkSize);

            CallRet callRet = client.CallWithBinary(url, "application/octet-stream", new MemoryStream(firstChunk, 0, blkSize), blkSize);

            if (callRet.OK)
            {
                return(QiniuJsonHelper.ToObject <BlkputRet>(callRet.Response));
            }
            return(null);
        }
Exemplo n.º 4
0
        private async Task <BlkputRet> MkblockAsync(Client client, byte[] firstChunk, int blkSize)
        {
            string url = string.Format("{0}/mkblk/{1}", Config.UP_HOST, blkSize);

            var content = new ByteArrayContent(firstChunk, 0, blkSize);

            content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");

            CallRet callRet = await client.CallWithBinaryAsync(url, content);

            if (callRet.OK)
            {
                return(QiniuJsonHelper.ToObject <BlkputRet>(callRet.Response));
            }
            return(null);
        }
Exemplo n.º 5
0
 public override string ToString()
 {
     return(QiniuJsonHelper.JsonEncode(this));
 }