From fe8b755406dc8d0948d5594ce511ec418f4e0683 Mon Sep 17 00:00:00 2001 From: Jaex Date: Sat, 20 Jun 2015 09:36:44 +0300 Subject: [PATCH] Added dropfile.to file uploader --- ShareX.UploadersLib/Enums.cs | 2 + ShareX.UploadersLib/FileUploaders/Dropfile.cs | 60 +++++++++++++++++++ ShareX.UploadersLib/FileUploaders/VideoBin.cs | 33 ++++++++-- .../ShareX.UploadersLib.csproj | 1 + ShareX/UploadTask.cs | 3 + 5 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 ShareX.UploadersLib/FileUploaders/Dropfile.cs diff --git a/ShareX.UploadersLib/Enums.cs b/ShareX.UploadersLib/Enums.cs index 2136708b9..93976f2f6 100644 --- a/ShareX.UploadersLib/Enums.cs +++ b/ShareX.UploadersLib/Enums.cs @@ -122,6 +122,8 @@ public enum FileDestination Imgrush, [Description("VideoBin")] VideoBin, + [Description("Dropfile")] + Dropfile, SharedFolder, // Localized Email, // Localized CustomFileUploader // Localized diff --git a/ShareX.UploadersLib/FileUploaders/Dropfile.cs b/ShareX.UploadersLib/FileUploaders/Dropfile.cs new file mode 100644 index 000000000..cdedf183d --- /dev/null +++ b/ShareX.UploadersLib/FileUploaders/Dropfile.cs @@ -0,0 +1,60 @@ +#region License Information (GPL v3) + +/* + ShareX - A program that allows you to take screenshots and share any file type + Copyright © 2007-2015 ShareX Developers + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + Optionally you can also view the license at . +*/ + +#endregion License Information (GPL v3) + +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; + +namespace ShareX.UploadersLib.FileUploaders +{ + public sealed class Dropfile : FileUploader + { + public override UploadResult Upload(Stream stream, string fileName) + { + UploadResult result = UploadData(stream, "https://dropfile.to/upload", fileName); + + if (result.IsSuccess) + { + DropfileResponse response = JsonConvert.DeserializeObject(result.Response); + + if (response != null && response.Status == 0) + { + result.URL = response.URL; + } + } + + return result; + } + + private class DropfileResponse + { + public int Status { get; set; } + public string URL { get; set; } + } + } +} \ No newline at end of file diff --git a/ShareX.UploadersLib/FileUploaders/VideoBin.cs b/ShareX.UploadersLib/FileUploaders/VideoBin.cs index 7d33cdf1a..bb55eeca0 100644 --- a/ShareX.UploadersLib/FileUploaders/VideoBin.cs +++ b/ShareX.UploadersLib/FileUploaders/VideoBin.cs @@ -1,4 +1,29 @@ -using System.Collections.Generic; +#region License Information (GPL v3) + +/* + ShareX - A program that allows you to take screenshots and share any file type + Copyright © 2007-2015 ShareX Developers + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + Optionally you can also view the license at . +*/ + +#endregion License Information (GPL v3) + +using System.Collections.Generic; using System.IO; namespace ShareX.UploadersLib.FileUploaders @@ -6,16 +31,16 @@ namespace ShareX.UploadersLib.FileUploaders public sealed class VideoBin : FileUploader { private const string URLUpload = "https://videobin.org/add"; - + public override UploadResult Upload(Stream stream, string fileName) { Dictionary arguments = new Dictionary(); arguments.Add("api", "1"); UploadResult result = UploadData(stream, URLUpload, fileName, "videoFile", arguments); - + result.URL = result.Response; - + return result; } } diff --git a/ShareX.UploadersLib/ShareX.UploadersLib.csproj b/ShareX.UploadersLib/ShareX.UploadersLib.csproj index 5c3a2dad0..3a93ab7ae 100644 --- a/ShareX.UploadersLib/ShareX.UploadersLib.csproj +++ b/ShareX.UploadersLib/ShareX.UploadersLib.csproj @@ -106,6 +106,7 @@ + diff --git a/ShareX/UploadTask.cs b/ShareX/UploadTask.cs index be49edac3..ab7ca4fe8 100644 --- a/ShareX/UploadTask.cs +++ b/ShareX/UploadTask.cs @@ -1003,6 +1003,9 @@ public UploadResult UploadFile(Stream stream, string fileName) case FileDestination.VideoBin: fileUploader = new VideoBin(); break; + case FileDestination.Dropfile: + fileUploader = new Dropfile(); + break; } if (fileUploader != null)