コード例 #1
0
        /// <summary>
        /// Upload a single File to Imgur
        /// </summary>
        /// <param name="file">Path to Image</param>
        public static async Task UploadSingle(string file)
        {
            ImgurUploader imgur = await GetUploaderAsync();

            using (MemoryStream stream = new MemoryStream()) {
                try {
                    //Binary Image
                    using (FileStream fstream = new FileStream(file, FileMode.Open, FileAccess.Read)) {
                        await fstream.CopyToAsync(stream);

                        //Set Stream Position to 0
                        stream.Position = 0;
                    }

                    //Image Size
                    string kb = $"{stream.Length / 1024d:0.#}";

                    //e.g. "Uploading Image (123KB)"
                    ShowNotification(string.Format(strings.uploading, kb), NotificationType.Progress, false);

                    string link = await imgur.Upload(stream);

                    await ClipboardHelper.CopyLink(link, false);

                    Notification?.Close();
                } catch {
                    //Unsupported File Type? Internet connection error?
                    await ShowNotificationAsync(strings.errorInstantUpload, NotificationType.Error, ActionTroubleshoot);
                }
            }

            await Task.Delay(500);

            Application.Current.Shutdown(0);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var uploader = new ImgurUploader();
            var result   = uploader.Upload("fb39e7076e0e8cd",
                                           new ImageData(File.ReadAllBytes(@"C:\Users\Public\Pictures\Sample Pictures\Desert.jpg"))
            {
                Title       = "Testing",
                Description = "A Testing DESC"
            });

            Console.WriteLine(result);
            Console.ReadLine();
        }
コード例 #3
0
        /// <summary>
        /// Upload the image to the specified host
        /// </summary>
        /// <param name="img"></param>
        public static void Upload(System.Drawing.Bitmap img)
        {
            switch (Config.conf.Uploader.ToLower())
            {
            default:
            case "imgur":
                ImgurUploader.Upload(Image.bitmapToBase64(img));
                break;

            case "vgyme":
                VgyMeUploader.Upload(img);
                break;

            case "gyazo":
                GyazoUploader.Upload(img);
                break;
            }
        }