Пример #1
0
        public async Task ShouldCorrectlyUploadFileByPath()
        {
            long           length;
            IUploadRequest completedRequest;
            var            tempFilePath = Path.GetTempFileName() + ".mp4";

            using (var fs = new FileStream(tempFilePath, FileMode.CreateNew))
            {
                await TestHelper.GetFileFromEmbeddedResources(TestHelper.TestFilePath).CopyToAsync(fs);
            }

            using (var file = new BinaryContent(tempFilePath))
            {
                file.ContentType.ShouldBe("video/mp4");
                length           = file.Data.Length;
                completedRequest = await AuthenticatedClient.UploadEntireFileAsync(file);

                completedRequest.ClipId.ShouldNotBeNull();
                await AuthenticatedClient.DeleteVideoAsync(completedRequest.ClipId.Value);
            }

            completedRequest.ShouldNotBeNull();
            completedRequest.IsVerifiedComplete.ShouldBeTrue();
            completedRequest.BytesWritten.ShouldBe(length);
            completedRequest.ClipUri.ShouldNotBeNull();
            completedRequest.ClipId.ShouldNotBeNull();
            completedRequest.ClipId?.ShouldBeGreaterThan(0);
            if (File.Exists(tempFilePath))
            {
                File.Delete(tempFilePath);
            }
        }
Пример #2
0
        public async Task ShouldCorrectlyGenerateNewTusResumableUploadTicket()
        {
            var ticket = await AuthenticatedClient.GetTusResumableUploadTicketAsync(1000);

            ticket.ShouldNotBeNull();
            ticket.Upload.UploadLink.ShouldNotBeEmpty();
            ticket.Id.ShouldNotBeNull();
            ticket.User.Id.ShouldBe(VimeoSettings.UserId);
            await AuthenticatedClient.DeleteVideoAsync(ticket.Id.Value);
        }