本文整理汇总了C#中UploadResult类的典型用法代码示例。如果您正苦于以下问题:C# UploadResult类的具体用法?C# UploadResult怎么用?C# UploadResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UploadResult类属于命名空间,在下文中一共展示了UploadResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: UploadText
public override UploadResult UploadText(string text, string fileName)
{
UploadResult result = new UploadResult();
if (!string.IsNullOrEmpty(text))
{
Dictionary<string, string> args = new Dictionary<string, string>();
args.Add("secret", text);
NameValueCollection headers = null;
if (!string.IsNullOrEmpty(API_USERNAME) && !string.IsNullOrEmpty(API_KEY))
{
headers = CreateAuthenticationHeader(API_USERNAME, API_KEY);
}
result.Response = SendRequest(HttpMethod.POST, API_ENDPOINT, args, headers);
if (!string.IsNullOrEmpty(result.Response))
{
OneTimeSecretResponse jsonResponse = JsonConvert.DeserializeObject<OneTimeSecretResponse>(result.Response);
if (jsonResponse != null)
{
result.URL = URLHelpers.CombineURL("https://onetimesecret.com/secret/", jsonResponse.secret_key);
}
}
}
return result;
}
开发者ID:noscripter,项目名称:ShareX,代码行数:31,代码来源:OneTimeSecret.cs
示例2: ShortenURL
public override UploadResult ShortenURL(string url)
{
UploadResult result = new UploadResult { URL = url };
if (!string.IsNullOrEmpty(url))
{
Dictionary<string, string> arguments = new Dictionary<string, string>();
arguments.Add("url", url);
result.Response = SendRequest(HttpMethod.GET, "http://turl.ca/api.php", arguments);
if (!string.IsNullOrEmpty(result.Response))
{
if (result.Response.StartsWith("SUCCESS:"))
{
result.ShortenedURL = "http://turl.ca/" + result.Response.Substring(8);
}
if (result.Response.StartsWith("ERROR:"))
{
Errors.Add(result.Response.Substring(6));
}
}
}
return result;
}
开发者ID:barsv,项目名称:ShareX,代码行数:27,代码来源:TurlURLShortener.cs
示例3: Upload
public override UploadResult Upload(Stream stream, string fileName)
{
UploadResult result = new UploadResult();
fileName = Helpers.GetValidURL(fileName);
string path = Account.GetSubFolderPath(fileName);
using (ftpClient = new FTP(Account, BufferSize))
{
ftpClient.ProgressChanged += OnProgressChanged;
try
{
IsUploading = true;
ftpClient.UploadData(stream, path);
}
finally
{
IsUploading = false;
}
}
if (!stopUpload && Errors.Count == 0)
{
result.URL = Account.GetUriPath(fileName);
}
return result;
}
开发者ID:petronas,项目名称:ShareX,代码行数:29,代码来源:FTPUploader.cs
示例4: Upload
public override UploadResult Upload(Stream stream, string fileName)
{
UploadResult result = new UploadResult();
string subFolderPath = Account.GetSubFolderPath();
string path = subFolderPath.CombineURL(fileName);
string url = Account.GetUriPath(fileName, subFolderPath);
OnEarlyURLCopyRequested(url);
try
{
IsUploading = true;
bool uploadResult = UploadStream(stream, path);
if (uploadResult && !StopUploadRequested && !IsError)
{
result.URL = url;
}
}
finally
{
Dispose();
IsUploading = false;
}
return result;
}
开发者ID:Grifs99,项目名称:ShareX,代码行数:28,代码来源:SFTP.cs
示例5: ParseResult
private UploadResult ParseResult(UploadResult result)
{
if (result.IsSuccess)
{
XDocument xd = XDocument.Parse(result.Response);
XElement xe = xd.Element("image");
if (xe != null)
{
string id = xe.GetElementValue("id");
result.URL = "http://twitsnaps.com/snap/" + id;
result.ThumbnailURL = "http://twitsnaps.com/thumb/" + id;
}
else
{
xe = xd.Element("error");
if (xe != null)
{
Errors.Add("Error: " + xe.GetElementValue("description"));
}
}
}
return result;
}
开发者ID:andre-d,项目名称:ShareXYZ,代码行数:27,代码来源:TwitSnapsUploader.cs
示例6: UploadSolution
public ActionResult UploadSolution(int id, HttpPostedFileBase file)
{
ActionResult redirectResult = this.RedirectToAction(
"Details",
"Courses",
new { area = "Public", id = id });
UploadResult result = new UploadResult();
if (file == null)
{
return redirectResult;
}
this.UserManagement.EnsureFolder(this.UserId);
result = this.UserManagement.SaveSolution(file, this.UserId, id);
if (!result.HasSucceed)
{
this.TempData["Error"] = result.Error;
}
else
{
this.courseService.SaveSolution(result.Path, this.UserId, id);
}
return redirectResult;
}
开发者ID:M-Yankov,项目名称:UniversityStudentSystem,代码行数:26,代码来源:CoursesController.cs
示例7: ShortenURL
public override UploadResult ShortenURL(string url)
{
if (customUploader.RequestType == CustomUploaderRequestType.POST && !string.IsNullOrEmpty(customUploader.FileFormName))
throw new Exception("'File form name' cannot be used with custom URL shortener.");
if (customUploader.Arguments == null || !customUploader.Arguments.Any(x => x.Value.Contains("$input$") || x.Value.Contains("%input")))
throw new Exception("Atleast one '$input$' required for argument value.");
UploadResult result = new UploadResult { URL = url };
Dictionary<string, string> args = customUploader.GetArguments(url);
result.Response = SendRequest(customUploader.GetHttpMethod(), customUploader.GetRequestURL(), args, customUploader.GetHeaders(), responseType: customUploader.ResponseType);
try
{
customUploader.ParseResponse(result, true);
}
catch (Exception e)
{
Errors.Add(Resources.CustomFileUploader_Upload_Response_parse_failed_ + Environment.NewLine + e);
}
return result;
}
开发者ID:Grifs99,项目名称:ShareX,代码行数:25,代码来源:CustomURLShortener.cs
示例8: UploadText
public override UploadResult UploadText(string text, string fileName)
{
UploadResult ur = new UploadResult();
if (!string.IsNullOrEmpty(text))
{
if (string.IsNullOrEmpty(APIKey))
{
APIKey = "public";
}
Dictionary<string, string> arguments = new Dictionary<string, string>();
arguments.Add("key", APIKey);
arguments.Add("description", "");
arguments.Add("paste", text);
arguments.Add("format", "simple");
arguments.Add("return", "link");
ur.Response = SendRequest(HttpMethod.POST, "http://paste.ee/api", arguments);
if (!string.IsNullOrEmpty(ur.Response) && ur.Response.StartsWith("error"))
{
Errors.Add(ur.Response);
}
else
{
ur.URL = ur.Response;
}
}
return ur;
}
开发者ID:RailTracker,项目名称:ShareX,代码行数:32,代码来源:Paste_ee.cs
示例9: ShortenURL
public override UploadResult ShortenURL(string url)
{
if (customUploader.RequestType == CustomUploaderRequestType.POST && !string.IsNullOrEmpty(customUploader.FileFormName))
throw new Exception("'File form name' cannot be used with custom URL shortener.");
if (string.IsNullOrEmpty(customUploader.RequestURL)) throw new Exception("'Request URL' must be not empty.");
if (customUploader.Arguments == null || !customUploader.Arguments.Any(x => x.Value.Contains("%input") || x.Value.Contains("$input$")))
throw new Exception("Atleast one '%input' or '$input$' required for argument value when using custom URL shortener.");
UploadResult result = new UploadResult { URL = url };
Dictionary<string, string> args = customUploader.ParseArguments(url);
if (customUploader.RequestType == CustomUploaderRequestType.POST)
{
result.Response = SendRequest(HttpMethod.POST, customUploader.RequestURL, args, customUploader.ResponseType);
}
else if (customUploader.RequestType == CustomUploaderRequestType.GET)
{
result.Response = SendRequest(HttpMethod.GET, customUploader.RequestURL, args, customUploader.ResponseType);
}
customUploader.ParseResponse(result, true);
return result;
}
开发者ID:Z1ni,项目名称:ShareX,代码行数:27,代码来源:CustomURLShortener.cs
示例10: ShortenURL
public override UploadResult ShortenURL(string url)
{
UploadResult result = new UploadResult { URL = url };
if (string.IsNullOrEmpty(API_HOST))
{
API_HOST = "https://polr.me/publicapi.php";
API_KEY = null;
}
else
{
API_HOST = URLHelpers.FixPrefix(API_HOST);
}
Dictionary<string, string> args = new Dictionary<string, string>();
if (!string.IsNullOrEmpty(API_KEY))
{
args.Add("apikey", API_KEY);
}
args.Add("action", "shorten");
args.Add("url", url);
string response = SendRequest(HttpMethod.GET, API_HOST, args);
if (!string.IsNullOrEmpty(response))
{
result.ShortenedURL = response;
}
return result;
}
开发者ID:Xanaxiel,项目名称:ShareX,代码行数:33,代码来源:PolrURLShortener.cs
示例11: ShortenURL
public override UploadResult ShortenURL(string url)
{
UploadResult result = new UploadResult { URL = url };
if (!string.IsNullOrEmpty(url))
{
Dictionary<string, string> arguments = new Dictionary<string, string>();
if (!string.IsNullOrEmpty(Signature))
{
arguments.Add("signature", Signature);
}
else if (!string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password))
{
arguments.Add("username", Username);
arguments.Add("password", Password);
}
else
{
throw new Exception("Signature or Username/Password is missing.");
}
arguments.Add("action", "shorturl");
arguments.Add("url", url);
//arguments.Add("keyword", "");
//arguments.Add("title", "");
arguments.Add("format", "simple");
result.Response = SendRequest(HttpMethod.POST, APIURL, arguments);
result.ShortenedURL = result.Response;
}
return result;
}
开发者ID:Z1ni,项目名称:ShareX,代码行数:34,代码来源:YourlsURLShortener.cs
示例12: Upload
public override UploadResult Upload(Stream stream, string fileName)
{
UploadResult result = new UploadResult();
fileName = Helpers.GetValidURL(fileName);
string subFolderPath = Account.GetSubFolderPath();
string path = subFolderPath.CombineURL(fileName);
bool uploadResult;
try
{
IsUploading = true;
uploadResult = UploadStream(stream, path);
}
finally
{
Dispose();
IsUploading = false;
}
if (uploadResult && !StopUploadRequested && !IsError)
{
result.URL = Account.GetUriPath(fileName, subFolderPath);
}
return result;
}
开发者ID:barsv,项目名称:ShareX,代码行数:27,代码来源:SFTP.cs
示例13: Upload
public override UploadResult Upload(Stream stream, string fileName)
{
if (string.IsNullOrEmpty(Host))
{
throw new Exception("ownCloud Host is empty.");
}
if (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password))
{
throw new Exception("ownCloud Username or Password is empty.");
}
if (string.IsNullOrEmpty(Path))
{
Path = "/";
}
string path = URLHelpers.CombineURL(Path, fileName);
string url = URLHelpers.CombineURL(Host, "remote.php/webdav", path);
url = URLHelpers.FixPrefix(url);
NameValueCollection headers = CreateAuthenticationHeader(Username, Password);
SSLBypassHelper sslBypassHelper = null;
try
{
if (IgnoreInvalidCert)
{
sslBypassHelper = new SSLBypassHelper();
}
string response = SendRequestStream(url, stream, Helpers.GetMimeType(fileName), headers, method: HttpMethod.PUT);
UploadResult result = new UploadResult(response);
if (!IsError)
{
if (CreateShare)
{
AllowReportProgress = false;
result.URL = ShareFile(path);
}
else
{
result.IsURLExpected = false;
}
}
return result;
}
finally
{
if (sslBypassHelper != null)
{
sslBypassHelper.Dispose();
}
}
}
开发者ID:barsv,项目名称:ShareX,代码行数:58,代码来源:OwnCloud.cs
示例14: OnLoad
protected override void OnLoad(EventArgs e)
{
UploadResult result = new UploadResult();
string typeId = (Request.Form["typeid"] ?? string.Empty).Trim();
result.CurrentTypeId = typeId;
string formPath = "music/";
int maxFileSize = SettingConfigUtility.UploadFileMaxSize * 1000;
if (Request.Files.Count > 0)
{
HttpPostedFile file = Request.Files[0];
if (file == null)
{
result.IsSuccess = false;
result.Message = "没有检测到<br>系统上传的音频文件";
this.RenderUploadResult(result);
}
else
{
string fileName = file.FileName;
fileName = Path.GetFileName(fileName);
int fileSize = file.ContentLength;
if (fileSize > 0)
{
if (fileSize > maxFileSize)
{
result.IsSuccess = false;
result.FileName = fileName;
result.Message = string.Format("因音频大于{0}KB", SettingConfigUtility.UploadFileMaxSize);
this.RenderUploadResult(result);
}
try
{
file.SaveAs(Server.MapPath(formPath + fileName));
}
catch (Exception)
{
result.IsSuccess = false;
result.FileName = fileName;
result.Message = "因上传出现未知错误";
this.RenderUploadResult(result);
}
result.IsSuccess = true;
result.FileName = fileName;
this.RenderUploadResult(result);
}
else
{
result.IsSuccess = false;
result.FileName = fileName;
result.Message = "因音频太小";
this.RenderUploadResult(result);
}
}
}
base.OnLoad(e);
}
开发者ID:KevinXu816,项目名称:ExamineSystem,代码行数:58,代码来源:pageupfileback.aspx.cs
示例15: ProcessRequest
public void ProcessRequest(HttpContext context) {
context.Response.ContentType = "text/plain";
var uploads = new List<UploadFileInfo>();
var basePath = HttpContext.Current.Request.Form["path"];
if (!basePath.StartsWith(SiteSettings.Instance.FilePath)) {
var exception = new AccessViolationException(string.Format("Wrong path for uploads! {0}", basePath));
Logger.Write(exception, Logger.Severity.Major);
throw exception;
}
basePath = HttpContext.Current.Server.MapPath(basePath);
foreach (string file in context.Request.Files) {
var postedFile = context.Request.Files[file];
string fileName;
if (postedFile.ContentLength == 0) {
continue;
}
if (postedFile.FileName.Contains("\\")) {
string[] parts = postedFile.FileName.Split(new[] {'\\'});
fileName = parts[parts.Length - 1];
}
else {
fileName = postedFile.FileName;
}
if (IsFileExtensionBlocked(fileName)) {
Logger.Write(string.Format("Upload of {0} blocked since file type is not allowed.", fileName), Logger.Severity.Major);
uploads.Add(new UploadFileInfo {
name = Path.GetFileName(fileName),
size = postedFile.ContentLength,
type = postedFile.ContentType,
error = "Filetype not allowed!"
});
continue;
}
var savedFileName = GetUniqueFileName(basePath, fileName);
postedFile.SaveAs(savedFileName);
uploads.Add(new UploadFileInfo {
name = Path.GetFileName(savedFileName),
size = postedFile.ContentLength,
type = postedFile.ContentType
});
}
var uploadResult = new UploadResult(uploads);
var serializedUploadInfo = Serialization.JsonSerialization.SerializeJson(uploadResult);
context.Response.Write(serializedUploadInfo);
}
开发者ID:KalikoCMS,项目名称:KalikoCMS.Core,代码行数:56,代码来源:FileHandler.ashx.cs
示例16: TaskInfo
public TaskInfo(TaskSettings taskSettings)
{
if (taskSettings == null)
{
taskSettings = TaskSettings.GetDefaultTaskSettings();
}
TaskSettings = taskSettings;
Result = new UploadResult();
}
开发者ID:Z1ni,项目名称:ShareX,代码行数:10,代码来源:TaskInfo.cs
示例17: TranscodeFile
private void TranscodeFile(UploadResult result)
{
StreamableTranscodeResponse transcodeResponse = JsonConvert.DeserializeObject<StreamableTranscodeResponse>(result.Response);
if (!string.IsNullOrEmpty(transcodeResponse.Shortcode))
{
ProgressManager progress = new ProgressManager(100);
if (AllowReportProgress)
{
OnProgressChanged(progress);
}
while (!StopUploadRequested)
{
string statusJson = SendRequest(HttpMethod.GET, URLHelpers.CombineURL(Host, "videos", transcodeResponse.Shortcode));
StreamableStatusResponse response = JsonConvert.DeserializeObject<StreamableStatusResponse>(statusJson);
if (response.Status > 2)
{
result.Errors.Add(response.Message);
result.IsSuccess = false;
break;
}
else if (response.Status == 2)
{
if (AllowReportProgress)
{
long delta = 100 - progress.Position;
progress.UpdateProgress(delta);
OnProgressChanged(progress);
}
result.IsSuccess = true;
result.URL = URLHelpers.CombineURL("https://streamable.com", transcodeResponse.Shortcode);
break;
}
if (AllowReportProgress)
{
long delta = response.Percent - progress.Position;
progress.UpdateProgress(delta);
OnProgressChanged(progress);
}
Thread.Sleep(100);
}
}
else
{
result.Errors.Add("Could not create video");
result.IsSuccess = false;
}
}
开发者ID:Maximus325,项目名称:ShareX,代码行数:54,代码来源:Streamable.cs
示例18: UploadText
public override UploadResult UploadText(string text, string fileName)
{
UploadResult ur = new UploadResult();
if (!string.IsNullOrEmpty(text))
{
string domain;
if (!string.IsNullOrEmpty(CustomDomain))
{
domain = CustomDomain;
}
else
{
domain = "http://hastebin.com";
}
ur.Response = SendRequest(HttpMethod.POST, URLHelpers.CombineURL(domain, "documents"), text);
if (!string.IsNullOrEmpty(ur.Response))
{
HastebinResponse response = JsonConvert.DeserializeObject<HastebinResponse>(ur.Response);
if (response != null && !string.IsNullOrEmpty(response.Key))
{
string url = URLHelpers.CombineURL(domain, response.Key);
string syntaxHighlighting = SyntaxHighlighting;
if (UseFileExtension)
{
string ext = Helpers.GetFilenameExtension(fileName);
if (!string.IsNullOrEmpty(ext) && !ext.Equals("txt", StringComparison.InvariantCultureIgnoreCase))
{
syntaxHighlighting = ext.ToLowerInvariant();
}
}
if (!string.IsNullOrEmpty(syntaxHighlighting))
{
url += "." + syntaxHighlighting;
}
ur.URL = url;
}
}
}
return ur;
}
开发者ID:Rapti,项目名称:ShareX,代码行数:51,代码来源:Hastebin.cs
示例19: TranscodeFile
private void TranscodeFile(string key, UploadResult result)
{
Dictionary<string, string> args = new Dictionary<string, string>();
if (NoResize) args.Add("noResize", "true");
if (IgnoreExisting) args.Add("noMd5", "true");
string url = CreateQuery("https://upload.gfycat.com/transcodeRelease/" + key, args);
string transcodeJson = SendRequest(HttpMethod.GET, url);
GfycatTranscodeResponse transcodeResponse = JsonConvert.DeserializeObject<GfycatTranscodeResponse>(transcodeJson);
if (transcodeResponse.IsOk)
{
ProgressManager progress = new ProgressManager(10000);
if (AllowReportProgress)
{
OnProgressChanged(progress);
}
while (!StopUploadRequested)
{
string statusJson = SendRequest(HttpMethod.GET, "https://upload.gfycat.com/status/" + key);
GfycatStatusResponse response = JsonConvert.DeserializeObject<GfycatStatusResponse>(statusJson);
if (response.Error != null)
{
Errors.Add(response.Error);
result.IsSuccess = false;
break;
}
else if (response.GfyName != null)
{
result.IsSuccess = true;
result.URL = "https://gfycat.com/" + response.GfyName;
break;
}
if (AllowReportProgress && progress.UpdateProgress((progress.Length - progress.Position) / response.Time))
{
OnProgressChanged(progress);
}
Thread.Sleep(100);
}
}
else
{
Errors.Add(transcodeResponse.Error);
result.IsSuccess = false;
}
}
开发者ID:Grifs99,项目名称:ShareX,代码行数:51,代码来源:GfycatUploader.cs
示例20: ShortenURL
public override UploadResult ShortenURL(string url)
{
UploadResult result = new UploadResult { URL = url };
if (!string.IsNullOrEmpty(url))
{
Dictionary<string, string> arguments = new Dictionary<string, string>();
arguments.Add("url", url);
result.Response = result.ShortenedURL = SendRequest(HttpMethod.GET, "http://nl.cm/api/", arguments);
}
return result;
}
开发者ID:Edison6351,项目名称:ShareX,代码行数:14,代码来源:NlcmURLShortener.cs
注:本文中的UploadResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论