예제 #1
0
        public void TestDownloadBackedUpAsset()
        {
            var publicId     = GetUniquePublicId();
            var uploadParams = new ImageUploadParams()
            {
                File     = new FileDescription(m_testImagePath),
                PublicId = publicId,
                Backup   = true,
                Tags     = m_apiTag
            };

            m_cloudinary.Upload(uploadParams);
            m_cloudinary.DeleteResources(publicId);
            m_cloudinary.Restore(publicId);
            var getResourceParams = new GetResourceParams(publicId)
            {
                Versions = true
            };
            var getResourceResult = m_cloudinary.GetResource(getResourceParams);
            var assetId           = getResourceResult.AssetId;
            var versionId         = getResourceResult.Versions[0].VersionId;

            var assetBackedUpUrl = m_cloudinary.DownloadBackedUpAsset(assetId, versionId);

            Assert.True(assetBackedUpUrl.Contains(assetId));
            Assert.True(assetBackedUpUrl.Contains(versionId));
            Assert.True(UrlExists(assetBackedUpUrl));
        }
예제 #2
0
        public void TestUploadLocalVideo()
        {
            var uploadParams = new VideoUploadParams()
            {
                File = new FileDescription(m_testVideoPath),
                Tags = m_apiTag
            };

            var uploadResult = m_cloudinary.Upload(uploadParams);

            Assert.AreEqual(640, uploadResult.Width);
            Assert.AreEqual(320, uploadResult.Height);
            Assert.AreEqual(FILE_FORMAT_MP4, uploadResult.Format);
            Assert.NotNull(uploadResult.Audio);
            Assert.AreEqual("aac", uploadResult.Audio.Codec);
            Assert.NotNull(uploadResult.Video);
            Assert.AreEqual("h264", uploadResult.Video.Codec);

            var getResource = new GetResourceParams(uploadResult.PublicId)
            {
                ResourceType = ResourceType.Video
            };
            var info = m_cloudinary.GetResource(getResource);

            Assert.AreEqual(FILE_FORMAT_MP4, info.Format);
        }
예제 #3
0
        public async Task <GetResourceResult> GetUri(string pulbicId)
        {
            var getParams = new GetResourceParams(pulbicId);
            var result    = await cloudinary.GetResourceAsync(getParams);

            return(result);
        }
예제 #4
0
 public async Task <GetResourceResult> GetResourceAsync(GetResourceParams parameters)
 {
     using (
         var response = await Api.CallAsync(HttpMethod.Get,
                                            new UrlBuilder(Api.ApiUrlV.ResourceType("resources").Add(Api.GetCloudinaryParam(parameters.ResourceType)).Add(parameters.Type).Add(parameters.PublicId).BuildUrl(),
                                                           parameters.ToParamsDictionary()).ToString(), null, null, null))
     {
         return(await GetResourceResult.Parse(response));
     }
 }
예제 #5
0
        public void TestGetResourceParamsDictionary()
        {
            var parameters = new GetResourceParams(TestConstants.TestPublicId)
            {
                CinemagraphAnalysis = true
            };

            var dictionary = parameters.ToParamsDictionary();

            Assert.AreEqual("true", dictionary["cinemagraph_analysis"]);
        }
        public Blob GetBlob(string path)
        {
            String            publicId       = GetFilenameFromPath(path);
            GetResourceParams resourceParams = new GetResourceParams(publicId);
            GetResourceResult result         = cloudinary.GetResource(resourceParams);
            WebClient         webClient      = new WebClient();
            Blob blob = new Blob();

            blob.Bytes = webClient.DownloadData(result.Url);
            return(blob);
        }
        public void TestGetResourceAccessibilityAnalysis()
        {
            var uploadResult      = UploadTestImageResource();
            var getResourceParams = new GetResourceParams(uploadResult.PublicId)
            {
                AccessibilityAnalysis = true
            };

            var getResult = m_cloudinary.GetResource(getResourceParams);

            CloudinaryAssert.AccessibilityAnalysisNotEmpty(getResult.AccessibilityAnalysis);
        }
        public void TestGetResourceCinemagraphAnalysis()
        {
            var uploadResult      = UploadTestImageResource();
            var getResourceParams = new GetResourceParams(uploadResult.PublicId)
            {
                CinemagraphAnalysis = true
            };

            var getResult = m_cloudinary.GetResource(getResourceParams);

            Assert.GreaterOrEqual(getResult.CinemagraphAnalysis.CinemagraphScore, 0);
        }
예제 #9
0
        public GetResourceResult GetResource(GetResourceParams parameters)
        {
            UrlBuilder urlBuilder = new UrlBuilder(
                m_api.ApiUrlV.
                ResourceType("resources").
                Add(Api.GetCloudinaryParam <ResourceType>(parameters.ResourceType)).
                Add(parameters.Type).Add(parameters.PublicId).
                BuildUrl(),
                parameters.ToParamsDictionary());

            using (HttpWebResponse response = m_api.Call(
                       HttpMethod.GET, urlBuilder.ToString(), null, null))
            {
                GetResourceResult result = GetResourceResult.Parse(response);
                return(result);
            }
        }
 public Task <GetResourceResult> GetResourceAsync(GetResourceParams parameters)
 {
     return(CallAsync(GetResource, parameters));
 }
 public static GetResourceResult GetResource(this Cloudinary cloudinary, GetResourceParams parameters)
 {
     return(cloudinary.GetResourceAsync(parameters).ExecSync());
 }