public static FolderAsset CreateFolder(this Session session)
        {
            var folder = FolderAsset.Create();

            session.AddAsset(folder);
            return(folder);
        }
Exemple #2
0
        public async Task <FileAsset?> Get(string key)
        {
            var fileName   = AssetUtils.GetHash(key);
            var sourcePath = Path.Join(BasePath, fileName);

            if (!File.Exists(sourcePath))
            {
                return(null);
            }

            var folder = FolderAsset.Create();
            var file   = folder.CreateFile("file");

            using var destination = File.Create(Path.Join(BasePath, file.AbsolutePath));
            using var source      = File.OpenRead(Path.Join(BasePath, fileName));
            await source.CopyToAsync(destination);

            return(file);
        }