public override void Move(FileSystemObject sourceFso, FileSystemObject targetFso, IFileStorageProvider targetProvider = null)
        {
            var sourceBytes = Get(sourceFso);

            if (sourceBytes == null)
            {
                throw new FileNotFoundException("File does not exist in memory provider", sourceFso.FullName);
            }

            if (TreatAsInMemoryProvider(targetProvider))
            {
                if (sourceFso.Equals(targetFso))
                {
                    return;
                }

                Store(sourceBytes, targetFso);
                Delete(sourceFso);

                return;
            }

            // Moving across providers (from in-memory to some other file provider), so store then delete source
            targetProvider.Store(sourceBytes, targetFso);
            Delete(sourceFso);
        }
Exemple #2
0
        private void CopyInFileSystem(FileSystemObject sourceFso, FileSystemObject targetFso)
        {
            if (sourceFso.Equals(targetFso))
            {
                return;
            }

            CreateFolder(targetFso.FolderName);
            File.Copy(sourceFso.FullName, targetFso.FullName, overwrite: true);
        }
Exemple #3
0
        private void MoveInFileSystem(FileSystemObject sourceFso, FileSystemObject targetFso)
        {
            if (sourceFso.Equals(targetFso))
            {
                return;
            }

            CreateFolder(targetFso.FolderName);
            File.Move(sourceFso.FullName, targetFso.FullName);
        }
Exemple #4
0
        private void MoveInS3(FileSystemObject sourceFso, FileSystemObject targetFso)
        {
            if (sourceFso.Equals(targetFso))
            {
                return;
            }

            // Copy, then delete
            CopyInS3(sourceFso, targetFso);
            Delete(sourceFso);
        }
Exemple #5
0
        private void CopyInS3(FileSystemObject sourceFso, FileSystemObject targetFso)
        {
            if (sourceFso.Equals(targetFso))
            {
                return;
            }

            var sourceBki = new S3BucketKeyInfo(sourceFso);
            var targetBki = new S3BucketKeyInfo(targetFso);

            var request = new CopyObjectRequest
            {
                SourceBucket      = sourceBki.BucketName,
                SourceKey         = sourceBki.Key,
                DestinationBucket = targetBki.BucketName,
                DestinationKey    = targetBki.Key
            };

            S3Client.CopyObject(request);
        }
        public override void Copy(FileSystemObject thisFso, FileSystemObject targetFso, IFileStorageProvider targetProvider = null)
        {
            var bytes = Get(thisFso);

            if (bytes == null)
            {
                throw new FileNotFoundException("File does not exist in memory provider", thisFso.FullName);
            }

            if (TreatAsInMemoryProvider(targetProvider))
            {
                if (thisFso.Equals(targetFso))
                {
                    return;
                }

                Store(bytes, targetFso);
                return;
            }

            targetProvider.Store(bytes, targetFso);
        }