コード例 #1
0
ファイル: VimeoManager.cs プロジェクト: erensavas/VimeoAlbum
        public async Task <VimeoDotNet.Net.IUploadRequest> VideoYukle(VimeoDotNet.Net.IBinaryContent content, int size)
        {
            VimeoDotNet.VimeoClient client1 = new VimeoDotNet.VimeoClient(TokenKey.Token);


            try
            {
                return(await client1.UploadEntireFileAsync(content, size));
            }
            catch (Exception ex)
            {
                return(null);
                //throw new Exception(ex.Message);
            }
        }
コード例 #2
0
        public async Task <string> uploadVideo()
        {
            var clientId       = "710f6c309030976b81f10290fc8a215815c2b74e";
            var clientSecret   = "8WIQG5etmifzzmaMgDxFiOPOklFEBxTFePtztNGkyaBYJZsvduKHHL+0Id/o9mcQEweBPFvmcq4jsR4GbEAl7TM91Q7gBjcE+gdYO2+Fcd+9VRTTACQZ4g4RIxK+d+GH";
            var redirectionUrl = "https://your_website_here.com/wherever-you-send-users-after-grant";

            var client = new VimeoDotNet.VimeoClient(clientId, clientSecret);

            fuVideoFile.SaveAs(@"D:\temp\" + fuVideoFile.FileName);
            VimeoDotNet.Net.BinaryContent _binaryContent = new VimeoDotNet.Net.BinaryContent(@"D:\temp\" + fuVideoFile.FileName);
            _binaryContent.ContentType      = fuVideoFile.PostedFile.ContentType;
            _binaryContent.OriginalFileName = fuVideoFile.PostedFile.FileName;
            var url = await client.UploadEntireFileAsync(_binaryContent);

            Console.WriteLine(url);
            Console.WriteLine("Give me your access code...");
            var accessCode = Console.ReadLine();
            var token      = await client.GetAccessTokenAsync(accessCode, redirectionUrl);

            return("");
        }
コード例 #3
0
        private bool UploadVideos(ref bool atLeastOneSuccess)
        {
            var success = true;

            try
            {
                var files    = SelectFiles();
                var vimeoApi = new VimeoDotNet.VimeoClient(Token);
                foreach (var file in files)
                {
                    try
                    {
                        XDocument xdoc = XDocument.Load(file.Path);

                        foreach (var xvideo in xdoc.XPathSelectElements("/Videos/Video"))
                        {
                            string title    = xvideo.Element("Title").Value;
                            string desc     = xvideo.Element("Description").Value;
                            string filePath = xvideo.Element("FilePath").Value;

                            try
                            {
                                using (var vfile = new BinaryContent(file.Path))
                                {
                                    var uploadTask = vimeoApi.UploadEntireFileAsync(vfile);
                                    uploadTask.Wait();
                                    var videoId = uploadTask.Result.ClipId;
                                    InfoFormat("Video {0} uploaded to Vimeo. VideoId: {1}", filePath, videoId);
                                }

                                if (success && !atLeastOneSuccess)
                                {
                                    atLeastOneSuccess = true;
                                }
                            }
                            catch (Exception e)
                            {
                                ErrorFormat("An error occured while uploading the file {0}: {1}", filePath, e.Message);
                                success = false;
                            }
                        }
                    }
                    catch (ThreadAbortException)
                    {
                        throw;
                    }
                    catch (Exception e)
                    {
                        ErrorFormat("An error occured while uploading the file {0}: {1}", file.Path, e.Message);
                        success = false;
                    }
                }
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (Exception e)
            {
                ErrorFormat("An error occured while uploading videos: {0}", e.Message);
                success = false;
            }
            return(success);
        }
コード例 #4
0
        public async Task <IHttpActionResult> Upload(Guid profileId)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                var hasVideoAlbum = db.Videos.Any(q => q.QrProfileId == profileId);
                var profile       = db.QrProfiles.First(q => q.Id == profileId);
                var profileName   = profile.FirstName + " " + profile.LastName;

                var provider = new MultipartFileStreamProvider(Path.GetTempPath());
                var content  = new StreamContent(HttpContext.Current.Request.GetBufferlessInputStream(true));
                foreach (var header in Request.Content.Headers)
                {
                    content.Headers.TryAddWithoutValidation(header.Key, header.Value);
                }
                var tsk = await content.ReadAsMultipartAsync(provider);

                var result   = new List <VideoFile>();
                var docfiles = new List <string>();
                foreach (var fileData in tsk.FileData)
                {
                    VideoFile videoFile = null;
                    // Sometimes the filename has a leading and trailing double-quote character
                    // when uploaded, so we trim it; otherwise, we get an illegal character exception
                    var fileName      = Path.GetFileName(fileData.Headers.ContentDisposition.FileName.Trim('"'));
                    var mediaType     = fileData.Headers.ContentType.MediaType;
                    var localFileName = fileData.LocalFileName;
                    using (var fileStream = File.OpenRead(fileData.LocalFileName))
                    {
                        fileStream.Position = 0;

                        //var client = new VimeoDotNet.VimeoClient("101df01f949f134370f77a375d8e169e7cc43ae8", "9rZXXj+4iRk8Wv95QPNNjf4sU+MI9+O7CczWnRp4L1dQF0V7hGeHA/bR0repqePh+TyvZNnRW2aFlWd34RD5JCfp7clj8nQuFZHRTxYjeSXwutIyJOSW/G9Sv5athNfB");
                        var  client       = new VimeoDotNet.VimeoClient("7510a353d5691dd4d17f90455d063329");
                        long?videoAlbumId = IsProd ? 4572966 : 4573995;
                        //if (!hasVideoAlbum)
                        //{
                        //    var editAlbumParameters = new VimeoDotNet.Parameters.EditAlbumParameters()
                        //    {
                        //        Description = $"Album for {profileName}",
                        //        Name = profileName,
                        //        Privacy = VimeoDotNet.Parameters.EditAlbumPrivacyOption.Anybody
                        //    };
                        //    var album = await client.CreateAlbumAsync(editAlbumParameters);
                        //    profile.VideoAlbumId = album.GetAlbumId().Value;
                        //}
                        //videoAlbumId = profile.VideoAlbumId;

                        var uploadRequest = await client.UploadEntireFileAsync(new BinaryContent(fileStream, fileData.Headers.ContentType.MediaType));

                        await client.AddToAlbumAsync(videoAlbumId.Value, uploadRequest.ClipId.Value);

                        videoFile                  = new VideoFile();
                        videoFile.QrProfileId      = profileId;
                        videoFile.UploadedByUserId = this.User.Identity.GetUserId();
                        videoFile.UploadedOn       = DateTime.Now;
                        videoFile.Extension        = Path.GetExtension(fileData.Headers.ContentDisposition.FileName.Replace("\"", ""));
                        videoFile.Url              = uploadRequest.ClipUri.Replace("videos", "video");
                        videoFile.ClipId           = uploadRequest.ClipId.Value;

                        db.Videos.Add(videoFile);

                        //var service = new BlobService();
                        //await service.UploadBlob( videoFile.Id.ToString(), mediaType, fileStream, BlobHelper.Repository.Video );
                        await db.SaveChangesAsync();
                    }
                    result.Add(videoFile);
                    File.Delete(fileData.LocalFileName);
                }
                return(Ok(result));
            }
            catch (InvalidDataException ex)
            {
                return(BadRequest(ex.Message));
            }
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: sabriozden/vimeo-client
        //video
        //my = 538100001



        public static async Task Upload(VimeoDotNet.VimeoClient userAuthenticatedClient)
        {
            var result = await userAuthenticatedClient.UploadEntireFileAsync(new BinaryContent(@"C:\Users\pc\Downloads\Test.mp4"));
        }