public override UploadResult Upload(Stream stream, string fileName)
        {
            string url = GetFolderLinkFromID(Config.MinusFolderActive.id, MinusScope.upload_new);

            Dictionary <string, string> args = new Dictionary <string, string>();

            args.Add("caption", fileName);
            args.Add("filename", fileName);

            string response = UploadData(stream, url, fileName, "file", args);

            UploadResult result = new UploadResult(response);

            if (!string.IsNullOrEmpty(response))
            {
                MinusFile minusFile = JsonConvert.DeserializeObject <MinusFile>(response);

                if (minusFile != null)
                {
                    result.ShortenedURL = string.Format("http://i.min.us/i{0}.jpg", minusFile.id);
                    result.URL          = string.Format("http://minus.com/i{0}.jpg", minusFile.id);
                    result.ThumbnailURL = minusFile.url_thumbnail;
                }
            }

            return(result);
        }
Example #2
0
        public override UploadResult Upload(Stream stream, string fileName)
        {
            if (!CheckAuthorization())
            {
                return(null);
            }

            string url = string.Format("{0}/folders/{1}/files?bearer_token={2}", URL_API, Config.GetActiveFolder().id, AuthInfo.Token.access_token);

            Dictionary <string, string> args = new Dictionary <string, string>();

            args.Add("caption", fileName);
            args.Add("filename", fileName);

            UploadResult result = UploadData(stream, url, fileName, "file", args);

            if (result.IsSuccess)
            {
                MinusFile minusFile = JsonConvert.DeserializeObject <MinusFile>(result.Response);

                if (minusFile != null)
                {
                    string ext = Path.GetExtension(minusFile.name);

                    switch (Config.LinkType)
                    {
                    case MinusLinkType.Direct:
                        result.URL = string.Format("http://i.minus.com/i{0}{1}", minusFile.id, ext);
                        break;

                    case MinusLinkType.Page:
                        result.URL = string.Format("http://minus.com/l{0}", minusFile.id);
                        break;

                    case MinusLinkType.Raw:
                        result.URL = minusFile.url_rawfile;
                        break;
                    }

                    result.ShortenedURL = string.Format("http://i.min.us/i{0}{1}", minusFile.id, ext);
                    result.ThumbnailURL = string.Format("http://i.minus.com/j{0}_xs{1}", minusFile.id, ext);
                }
            }

            return(result);
        }
Example #3
0
        public override UploadResult Upload(Stream stream, string fileName)
        {
            string url = GetFolderLinkFromID(Config.GetActiveFolder().id, MinusScope.upload_new);

            Dictionary <string, string> args = new Dictionary <string, string>();

            args.Add("caption", fileName);
            args.Add("filename", fileName);

            UploadResult result = UploadData(stream, url, fileName, "file", args);

            if (result.IsSuccess)
            {
                MinusFile minusFile = JsonConvert.DeserializeObject <MinusFile>(result.Response);

                if (minusFile != null)
                {
                    string ext = Path.GetExtension(minusFile.name);

                    switch (Config.LinkType)
                    {
                    case MinusLinkType.Direct:
                        result.URL = string.Format("http://i.minus.com/i{0}{1}", minusFile.id, ext);
                        break;

                    case MinusLinkType.Page:
                        result.URL = string.Format("http://minus.com/l{0}", minusFile.id);
                        break;

                    case MinusLinkType.Raw:
                        result.URL = minusFile.url_rawfile;
                        break;
                    }

                    result.ShortenedURL = string.Format("http://i.min.us/i{0}{1}", minusFile.id, ext);
                    result.ThumbnailURL = string.Format("http://i.minus.com/j{0}_xs{1}", minusFile.id, ext);
                }
            }

            return(result);
        }