Exemplo n.º 1
0
        protected override MultipartData GetRequestData(TypedData data)
        {
            var builder = new MultipartDataBuilder();
            builder.KeyValuePair("longurl", data.Data.ToString());

            return builder.GetData();
        }
Exemplo n.º 2
0
        protected override MultipartData GetRequestData(TypedData data)
        {
            var builder = new MultipartDataBuilder();
            builder.KeyValuePair("key", Settings.Default.imgurApiKey);
            builder.KeyValuePair("name", data.Name);
            builder.File((Stream) data.Data, "image", data.Name);

            return builder.GetData();
        }
Exemplo n.º 3
0
        protected override MultipartData GetRequestData(TypedData data)
        {
            var builder = new MultipartDataBuilder();
            builder.File((Stream) data.Data, "upload", data.Name);
            builder.KeyValuePairs(new Dictionary<string, string> {
                // FIXME Remove and adjust as required.  Just copy-pasted all
                // this from the main page.  (Don't shoot me.)
                { "mode", "local" },
                { "formurl", "http://www.postimage.org/" },
                { "tpl", "." },
                { "addform", "" },
                { "mforum", "" },
                { "um", "image" },
                { "adult", IsAdult ? "yes" : "no" },
                { "ui", "" },
                { "hash", "943" },
                { "optsize", "0" },
                { "submit", "Upload It!" },
            });

            return builder.GetData();
        }
Exemplo n.º 4
0
        protected override MultipartData GetRequestData(TypedData data)
        {
            var builder = new MultipartDataBuilder();
            builder.KeyValuePairs(new Dictionary<string, string> {
                { "raw_paste", data.Data.ToString() },
                { "comment", "" },
                { "author", Author ?? "" },
                { "language", Language ?? "text" },
                { "permissions", IsPrivate ? "1" : "0" },
                { "desc", data.Name ?? "" },
                { "linenumbers", ShowLineNumbers ? "0" : "1" },
                { "expire", Expiration.TotalSeconds.ToString(NumberFormatInfo.InvariantInfo) },
                { "submit", "Submit Paste" },
                { "tabbing", "true" },
                { "tabtype", "real" },
            });

            return builder.GetData();
        }
Exemplo n.º 5
0
        private static Uri UploadData(TypedData data, Uri uri, string uploadId, string uploadInfo, ulong maxFileSize, IMutableProgressTracker progress, CancellationToken cancelToken)
        {
            var postData = new MultipartDataBuilder()
                .KeyValuePair("MAX_FILE_SIZE", maxFileSize.ToString())
                .KeyValuePair("UPLOAD_IDENTIFIER", uploadId)
                .KeyValuePair("extra_info", uploadInfo)
                .File((Stream) data.Data, "userfile", data.Name)
                .GetData();

            var response = HttpRequest.Execute(uri, postData, HttpRequestMethod.Post, progress, cancelToken);

            string text = HttpRequest.GetResponseText(response);
            var match = new Regex(@"\bfile_id=(?<FileId>\S+)\b").Match(text);

            return new Uri(string.Format(OutputFileUriFormat, match.Groups["FileId"].Value), UriKind.Absolute);
        }
Exemplo n.º 6
0
        public TypedData Process(TypedData data, IMutableProgressTracker progress, CancellationToken cancelToken)
        {
            var parameters = new {
                FileName = data.Name,
            };

            var dataBuilder = new MultipartDataBuilder();

            foreach (var parameter in PostParameters) {
                if (parameter.Key == null) {
                    continue;
                }

                dataBuilder.KeyValuePair(parameter.Key, StringLib.HartFormatter.HartFormat(parameter.Value, parameters));
            }

            dataBuilder.File((Stream) data.Data, FileParameterName, data.Name);

            progress.Status = "Uploading data";

            var response = HttpRequest.Execute(Uri, dataBuilder.GetData(), HttpRequestMethod.Post, progress, cancelToken);

            return TypedData.FromUri(response.ResponseUri, data.Name);
        }
Exemplo n.º 7
0
        protected override MultipartData GetRequestData(TypedData data)
        {
            var builder = new MultipartDataBuilder();
            builder.File((Stream) data.Data, "f", data.Name);
            builder.KeyValuePairs(new Dictionary<string, string> {
                { "t", "file" },
                { "name", data.Name ?? "" },
                { "tags", Tags ?? "" },
                { "description", Description ?? "" },
                { "adult", IsPrivate ? "t" : "f" },
                { "sfile", "Upload" },
                { "url", "" },
            });

            return builder.GetData();
        }