예제 #1
0
 //Rename
 public async Task RenameFileAsync(MetadataEntity oldFile, MetadataEntity newFile)
 {
     IStor stor        = _config.Stors.First(s => s.ShortName == oldFile.StorName).GetStorFromConfig();
     var   oldFileName = oldFile.GetServerFileName();
     var   newFileName = newFile.GetServerFileName();
     await stor.RenameFileAsync(oldFileName, newFileName);
 }
예제 #2
0
        public async Task MoveDocumentVersion(DocumentVersionEntity verEntity, string newStorProvider)
        {
            try
            {
                IStor origStor = _config.Stors.First(s => s.ShortName == verEntity.StorName).GetStorFromConfig();
                IStor newStor  = _config.Stors.First(s => s.ShortName == newStorProvider).GetStorFromConfig();
                if (String.IsNullOrWhiteSpace(origStor.ShortName))
                {
                    throw new Exception("Unable to find old stor within config");
                }
                if (String.IsNullOrWhiteSpace(newStor.ShortName))
                {
                    throw new Exception("Unable to find new stor within config");
                }
                var    fileName = verEntity.GetServerFileName();
                string hash;
                using (var origStream = await origStor.GetFileAsync(fileName))
                {
                    await newStor.SetFileAsync(fileName, origStream);

                    hash = await newStor.GetFileHashAsync(fileName);

                    if (hash != verEntity.MD5Hash)
                    {
                        await newStor.RemoveFileAsync(fileName);

                        throw new Exception("File transfer failed MD5 hash is not equal");
                    }
                }
                await origStor.RemoveFileAsync(fileName);
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to move document see inner exception", ex);
            }
        }
예제 #3
0
 public async Task DeleteDocumentVersionAsync(DocumentVersionEntity verEntity)
 {
     IStor stor     = _config.Stors.First(s => s.ShortName == verEntity.StorName).GetStorFromConfig();
     var   fileName = verEntity.GetServerFileName();
     await stor.RemoveFileAsync(fileName);
 }
예제 #4
0
 //Deletes
 public async Task DeleteDocumentAsync(MetadataEntity meta)
 {
     IStor stor     = _config.Stors.First(s => s.ShortName == meta.StorName).GetStorFromConfig();
     var   fileName = meta.GetServerFileName();
     await stor.RemoveFileAsync(fileName);
 }