コード例 #1
0
ファイル: LinkUpload.cs プロジェクト: lbsbv/vzaar-api-net
        public static Video Create(Dictionary <string, object> tokens, Client client)
        {
            var link = new LinkUpload(client);

            var video = link.LinkCreate(tokens);

            return(video);
        }
コード例 #2
0
ファイル: LinkUpload.cs プロジェクト: lbsbv/vzaar-api-net
        public static Video Create(string url, Client client)
        {
            var link = new LinkUpload(client);

            var tokens = new Dictionary <string, object> ();

            tokens.Add("url", url);

            var video = link.LinkCreate(tokens);

            return(video);
        }
コード例 #3
0
        internal async Task <object> createDataAsync(Dictionary <string, object> tokens)
        {
            bool containsfile = tokens.ContainsKey("filepath");
            bool containsguid = tokens.ContainsKey("guid");
            bool containsurl  = tokens.ContainsKey("url");

            //to return Video created from LinkUpload, otherwise return null
            object result = null;

            if (((containsfile ^ containsguid) ^ containsurl) == true)
            {
                if (((containsfile & containsguid) & containsurl) == true)
                {
                    throw new VzaarApiException("Only one of the parameters: guid or url or filepath expected");
                }

                if (containsguid == true)
                {
                    record.Create(tokens);
                }
                else if (containsurl == true)
                {
                    result = LinkUpload.Create(tokens, record.RecordClient);
                }
                else
                {
                    string filepath = (string)tokens ["filepath"];

                    FileInfo file = new FileInfo(filepath);

                    if (file.Exists == false)
                    {
                        throw new VzaarApiException("File does not exist: " + filepath);
                    }

                    Signature signature = Signature.Create(filepath, record.RecordClient);

                    await record.RecordClient.HttpPostS3Async(filepath, signature);

                    tokens.Remove("filepath");
                    tokens.Add("guid", (string)signature ["guid"]);

                    await createDataAsync(tokens);
                }
            }
            else
            {
                throw new VzaarApiException();
            }

            return(result);
        }
コード例 #4
0
        public static void UsingLinkUploadParameters(string id, string token, string url)
        {
            try {
                Console.WriteLine("--Create()-from parameters--");

                Dictionary <string, object> tokens = new Dictionary <string, object> ()
                {
                    { "url", url },
                    { "uploader", "My Uploader" },
                    { "title", "My URL Movie" },
                    { "description", "Initial URL description" }
                };

                var video = LinkUpload.Create(tokens);

                Console.WriteLine("Id: " + video["id"] + " Title: " + video["title"]);

//				Console.WriteLine ("--Delete--");
//
//				var videoId = (long)video ["id"];
//				video.Delete ();
//
//				Console.WriteLine ("--Find after delete: id: "+videoId+"--");
//				var video1 = Video.Find (videoId);
            } catch (VzaarApiException ve) {
                Console.Write("!!!!!!!!! EXCEPTION !!!!!!!!!");
                Console.WriteLine(ve.Message);
            } catch (Exception e) {
                Console.Write("!!!!!!!!! EXCEPTION !!!!!!!!!");
                Console.WriteLine(e.Message);

                if (e is AggregateException)
                {
                    AggregateException ae = (AggregateException)e;

                    var flatten = ae.Flatten();

                    foreach (var fe in flatten.InnerExceptions)
                    {
                        if (fe is VzaarApiException)
                        {
                            Console.WriteLine(fe.Message);
                        }
                    }
                }
            }
        }
コード例 #5
0
        public static void UsingLinkUploadUrlString(string id, string token, string url)
        {
            try {
                Console.WriteLine("--Create()-from URL string--");

                var video = LinkUpload.Create(url);

                Console.WriteLine("Id: " + video["id"] + " Title: " + video["title"]);

                Console.WriteLine("--Delete--");

                var videoId = (long)video ["id"];
                video.Delete();

                Console.WriteLine("--Find after delete: id: " + videoId + "--");
                var video1 = Video.Find(videoId);
            } catch (VzaarApiException ve) {
                Console.Write("!!!!!!!!! EXCEPTION !!!!!!!!!");
                Console.WriteLine(ve.Message);
            } catch (Exception e) {
                Console.Write("!!!!!!!!! EXCEPTION !!!!!!!!!");
                Console.WriteLine(e.Message);

                if (e is AggregateException)
                {
                    AggregateException ae = (AggregateException)e;

                    var flatten = ae.Flatten();

                    foreach (var fe in flatten.InnerExceptions)
                    {
                        if (fe is VzaarApiException)
                        {
                            Console.WriteLine(fe.Message);
                        }
                    }
                }
            }
        }