private CallRet Mkfile(Client client, string key, long fsize) { EntryPath entry = new EntryPath (extra.Bucket, key); string url = string.Format ("{0}/rs-mkfile/{1}/fsize/{2}/", Config.UP_HOST, entry.Base64EncodedURI, fsize); if (!string.IsNullOrEmpty (extra.MimeType)) { url += (string.Format ("/mimeType/{0}", extra.MimeType.ToBase64URLSafe ())); } if (!string.IsNullOrEmpty (extra.CustomMeta)) { url += (string.Format ("/meta/{0}", extra.CustomMeta.ToBase64URLSafe ())); } if (!string.IsNullOrEmpty (extra.CallbackParams)) { url += (string.Format ("/params/{0}", extra.CallbackParams.ToBase64URLSafe ())); } int proCount = extra.Progresses.Length; using (Stream body = new MemoryStream()) { for (int i = 0; i < proCount; i++) { byte[] bctx = Encoding.ASCII.GetBytes (extra.Progresses [i].ctx); body.Write (bctx, 0, bctx.Length); if (i != proCount - 1) { body.WriteByte ((byte)','); } } body.Seek (0, SeekOrigin.Begin); return client.CallWithBinary (url, "text/plain", body, body.Length); } }
private BlkputRet Mkblock(Client client, byte[] firstChunk, long blkSize) { string url = string.Format ("{0}/mkblk/{1}", Config.UP_HOST, blkSize); CallRet callRet = client.CallWithBinary (url, "application/octet-stream", new MemoryStream (firstChunk), firstChunk.Length); if (callRet.OK) { return callRet.Response.ToObject<BlkputRet> (); } return null; }
private BlkputRet BlockPut(Client client, BlkputRet ret, Stream body, long length) { string url = string.Format ("{0}/bput/{1}/{2}", Config.UP_HOST, ret.ctx, ret.offset); CallRet callRet = client.CallWithBinary (url, "application/octet-stream", body, length); if (callRet.OK) { return callRet.Response.ToObject<BlkputRet> (); } return null; }
private async System.Threading.Tasks.Task<CallRet> Mkfile(Client client, string key, long fsize) { StringBuilder urlBuilder = new StringBuilder(); urlBuilder.AppendFormat("{0}/mkfile/{1}", Config.UP_HOST, fsize); if (key != null) { urlBuilder.AppendFormat("/key/{0}", Base64URLSafe.ToBase64URLSafe(key)); } if (!string.IsNullOrEmpty(extra.MimeType)) { urlBuilder.AppendFormat("/mimeType/{0}", Base64URLSafe.ToBase64URLSafe(extra.MimeType)); } if (!string.IsNullOrEmpty(extra.CustomMeta)) { urlBuilder.AppendFormat("/meta/{0}", Base64URLSafe.ToBase64URLSafe(extra.CustomMeta)); } if (extra.CallbackParams != null && extra.CallbackParams.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (string _key in extra.CallbackParams.Keys) { sb.AppendFormat("/{0}/{1}", _key, Base64URLSafe.ToBase64URLSafe(extra.CallbackParams[_key])); } urlBuilder.Append(sb.ToString()); } int proCount = extra.Progresses.Length; using (Stream body = new MemoryStream()) { for (int i = 0; i < proCount; i++) { byte[] bctx = Encoding.ASCII.GetBytes(extra.Progresses[i].ctx); body.Write(bctx, 0, bctx.Length); if (i != proCount - 1) { body.WriteByte((byte)','); } } body.Seek(0, SeekOrigin.Begin); return await client.CallWithBinary(urlBuilder.ToString(), "text/plain", body, body.Length); } }
private async System.Threading.Tasks.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, "application/octet-stream", new MemoryStream(firstChunk, 0, blkSize), blkSize); if (callRet.OK) { return QiniuJsonHelper.ToObject<BlkputRet>(callRet.Response); } return null; }
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; }