Example #1
0
        private async ValueTask <FileSystemFileReference> InternalGetAsync(string path, bool withMetadata,
                                                                           bool checkIfExists = true)
        {
            var fullPath = Path.Combine(AbsolutePath, path);

            if (checkIfExists && !File.Exists(fullPath))
            {
                return(null);
            }

            FileExtendedProperties extendedProperties = null;

            if (withMetadata)
            {
                extendedProperties = await _extendedPropertiesProvider.GetExtendedPropertiesAsync(
                    AbsolutePath,
                    new PrivateFileReference(path));
            }

            return(new FileSystemFileReference(
                       fullPath,
                       path,
                       this,
                       withMetadata,
                       extendedProperties,
                       _publicUrlProvider,
                       _extendedPropertiesProvider));
        }
        public FileSystemFileReference(
            string filePath,
            string path,
            AbpFileSystemStore store,
            bool withMetadata,
            FileExtendedProperties extendedProperties,
            IAbpPublicUrlProvider publicUrlProvider,
            IAbpExtendedPropertiesProvider extendedPropertiesProvider)
        {
            FileSystemPath = filePath;
            Path           = path.Replace('\\', '/');
            _store         = store;
            _extendedPropertiesProvider = extendedPropertiesProvider;
            _withMetadata = withMetadata;

            _propertiesLazy = new Lazy <IFileProperties>(() =>
            {
                if (withMetadata)
                {
                    return(new FileSystemFileProperties(FileSystemPath, extendedProperties));
                }

                throw new InvalidOperationException("Metadata are not loaded, please use withMetadata option");
            });

            _publicUrlLazy = new Lazy <string>(() =>
            {
                if (publicUrlProvider != null)
                {
                    return(publicUrlProvider.GetPublicUrl(_store.Name, this));
                }

                throw new InvalidOperationException("There is not Server enabled.");
            });
        }
 public FileSystemFileProperties(string fileSystemPath, FileExtendedProperties extendedProperties)
 {
     _fileInfo          = new FileInfo(fileSystemPath);
     ExtendedProperties = extendedProperties;
 }
Example #4
0
 public Task SaveExtendedPropertiesAsync(string storeAbsolutePath, IPrivateFileReference file, FileExtendedProperties extendedProperties)
 {
     throw new InvalidOperationException("There is no FileSystem extended properties provider.");
 }