public override string MakeRequest(string url) { StringBuilder sb = new StringBuilder(); sb.Append(string.Format("{0}?watermark/{1}", url, 2)); if (string.IsNullOrEmpty(text)) { throw new Exception("No Text To Draw"); } sb.Append("/text/" + Base64URLSafe.ToBase64URLSafe(text)); if (!string.IsNullOrEmpty(fontName)) { sb.Append("/font/" + Base64URLSafe.ToBase64URLSafe(fontName)); } if (fontSize > 0) { sb.Append("/fontsize/" + fontSize); } if (!string.IsNullOrEmpty(color)) { sb.Append("/fill/" + Base64URLSafe.ToBase64URLSafe(color)); } sb.Append("/dissolve/" + dissolve); sb.Append("/gravity/" + Gravitys[(int)gravity]); sb.Append("/dx/" + dx); sb.Append("/dy/" + dy); return(sb.ToString()); }
private async Task <CallRet> MkfileAsync(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); var content = new StreamContent(body); content.Headers.ContentType = new MediaTypeHeaderValue("text/plain"); return(await client.CallWithBinaryAsync(urlBuilder.ToString(), content)); } }
public override string MakeRequest(string url) { StringBuilder sb = new StringBuilder(); sb.Append(string.Format("{0}?watermark/{1}", url, 1)); if (string.IsNullOrEmpty(imageUrl)) { throw new Exception("Water Marker Image Url Error"); } sb.Append("/image/" + Base64URLSafe.ToBase64URLSafe(imageUrl)); sb.Append("/dissolve/" + dissolve); sb.Append("/gravity/" + Gravitys[(int)gravity]); sb.Append("/dx/" + dx); sb.Append("/dy/" + dy); return(sb.ToString()); }
private async 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 temp in Extra.CallbackParams.AllKeys /*Keys*/) { sb.AppendFormat("/{0}/{1}", temp, Base64URLSafe.ToBase64URLSafe(Extra.CallbackParams[temp])); } 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)); } }