public void NormalizePath_path_directoryValidation_failFile(string path)
        {
            var bunnyStorage = new BunnyCDNStorage("testingZone", string.Empty);

            var exception = Assert.Throws <BunnyCDNStorageException>(() => bunnyStorage.NormalizePath(path, false));

            Assert.Equal("The requested path is invalid, cannot be directory.", exception.Message);
        }
        public void NormalizePath_fixExtraSlashes()
        {
            var bunnyStorage = new BunnyCDNStorage("testingZone", string.Empty);

            var result = bunnyStorage.NormalizePath("testingZone//directory///path/file.txt");

            Assert.Equal("testingZone/directory/path/file.txt", result);
        }
        public void NormalizePath_path_directoryValidation_autoFix(string path, string expected)
        {
            var bunnyStorage = new BunnyCDNStorage("testingZone", string.Empty);

            var result = bunnyStorage.NormalizePath(path, true);

            Assert.Equal(expected, result);
        }
        public void NormalizePath_invalidZone(string path)
        {
            var bunnyStorage = new BunnyCDNStorage("testingZone", string.Empty);

            var exception = Assert.Throws <BunnyCDNStorageException>(() => bunnyStorage.NormalizePath(path));

            Assert.Equal("Path validation failed. File path must begin with /testingZone/.", exception.Message);
        }
        public void NormalizePath_valid()
        {
            var bunnyStorage = new BunnyCDNStorage("testingZone", string.Empty);
            var correctPath  = "testingZone/validPath/testFile.txt";

            var result = bunnyStorage.NormalizePath(correctPath);

            Assert.Equal(correctPath, result);
        }
        public void NormalizePath_fixWindows()
        {
            var    bunnyStorage = new BunnyCDNStorage("testingZone", string.Empty);
            string path         = "testingZone\\windows\\path\\shouldbeRectified";

            var result = bunnyStorage.NormalizePath(path);

            Assert.Equal(path.Replace("\\", "/"), result);
        }
Beispiel #7
0
        public async ValueTask <List <Series> > obterNomes()
        {
            var bunnyCDNStorage = new BunnyCDNStorage("api-animaflix", "754b2acf-9259-47e3-82c442a62716-ea28-4006", "de");
            var objects         = await bunnyCDNStorage.GetStorageObjectsAsync("/api-animaflix/");

            List <Series> series = new List <Series>();

            foreach (var x in objects)
            {
                String          cover    = "";
                List <Episodio> episodes = new List <Episodio>();
                if (x.IsDirectory)
                {
                    var objs = await bunnyCDNStorage.GetStorageObjectsAsync("/api-animaflix/" + x.ObjectName);

                    foreach (var y in objs)
                    {
                        if (y.IsDirectory)
                        {
                            var cc = await bunnyCDNStorage.GetStorageObjectsAsync("/api-animaflix/" + x.ObjectName + "/" + y.ObjectName);

                            foreach (var b in cc)
                            {
                                cover = BuildURI(b.FullPath);
                            }
                        }
                        else
                        {
                            Episodio a = new Episodio();
                            a.Id   = y.Guid;
                            a.Name = y.ObjectName;
                            a.Uri  = BuildURI(y.FullPath);

                            episodes.Add(a);
                        }
                    }
                }
                Series aa = new Series();
                aa.Name  = x.ObjectName;
                aa.eps   = episodes;
                aa.cover = cover;
                series.Add(aa);
            }

            return(series);
        }
 private static async Task UploadAsync(string storageZoneName, string apiAccessKey, string path)
 {
     try
     {
         Debug.Log("Starting upload...");
         var bunnyCdnStorage = new BunnyCDNStorage(storageZoneName, apiAccessKey);
         foreach (var file in Directory.EnumerateFiles(path, "*.*", SearchOption.AllDirectories))
         {
             var target = $"/{storageZoneName}/{file.Replace(path, "")}";
             Debug.Log($"Uploading {file} to {target}");
             await bunnyCdnStorage.UploadAsync(file, target);
         }
         Debug.Log("Upload completed");
     }
     catch (Exception e)
     {
         Debug.LogError("UploadToBunnyCDN Exception: " + e.Message);
     }
 }