Exemple #1
0
        protected internal override ulong DoGetItemSize(FileSystemSessionItem item)
        {
            var s3session = (S3V4FileSystemSession)item.Session;
            var handle    = item.Handle as S3V4FSH;

            FileSystemFile file = item as FileSystemFile;

            if (file != null)
            {
                IDictionary <string, string> metaHeaders = S3V4.GetItemMetadata(handle.Path,
                                                                                s3session.AccessKey, s3session.SecretKey, s3session.Bucket, s3session.Region, s3session.TimeoutMs);
                return((ulong)metaHeaders["Content-Length"].AsLong());
            }

            FileSystemDirectory dir = item as FileSystemDirectory;

            if (dir != null)
            {
                ulong size = 0;
                foreach (S3V4ListBucketItem subItem in getSubitemNames(dir, true).Where(si => !si.IsFolder))
                {
                    size += subItem.Size;
                }
                return(size);
            }

            throw new NFXException(NFX.Web.StringConsts.ARGUMENT_ERROR + this.GetType().Name + ".DoGetItemSize(item is FileSystemFile or FileSystemDirectory)");
        }
Exemple #2
0
        protected internal override DateTime?DoGetModificationTimestamp(FileSystemSessionItem item)
        {
            var s3session = (S3V4FileSystemSession)item.Session;
            var handle    = item.Handle as S3V4FSH;

            var metaHeaders = S3V4.GetItemMetadata(handle.Path, s3session.AccessKey, s3session.SecretKey, s3session.Bucket, s3session.Region,
                                                   s3session.TimeoutMs);

            return(metaHeaders["Last-Modified"].AsDateTime());
        }