internal ISupportingFile UpdateFile(VersionedSupportingFile file, Stream newContents, string fileName) { //update the file contents string newStoragePath = _fileService.FileStorage.CreateFile(fileName); using (Stream outStream = new FileStream(newStoragePath, FileMode.OpenOrCreate, FileAccess.Write)) StreamHelper.Transfer(newContents, outStream); //if the filename is changing, assign the file a new unique filename token string fileNameUniqueToken = fileName == file.FileName ? file.FileNameUniqueToken : _fileService.CreateUniqueFileNameToken(fileName); //Clone the file so that its old version can still be referenced by its old URL. //Note: this is required since editor undo operations may allow the post to rollback //to referencing the old version of the file. VersionedSupportingFile newFile = new VersionedSupportingFile(this, _nextVersion++, new Uri(UrlHelper.CreateUrlFromPath(newStoragePath)), fileName, fileNameUniqueToken, true, (BlogPostSettingsBag)file.Settings.Clone());; newFile.StoragePath = newStoragePath; RegisterSupportingFile(newFile); return(newFile); }
private void Delete(VersionedSupportingFile file) { _fileService.DeregisterSupportingFile(file); _versionTable.Remove(file.FileVersion); }
private ISupportingFile RegisterSupportingFile(VersionedSupportingFile file) { _versionTable[file.FileVersion] = file; _fileService.RegisterSupportingFile(file); return(file); }
internal ISupportingFile UpdateFile(VersionedSupportingFile file, Stream newContents, string fileName) { //update the file contents string newStoragePath = _fileService.FileStorage.CreateFile(fileName); using (Stream outStream = new FileStream(newStoragePath, FileMode.OpenOrCreate, FileAccess.Write)) StreamHelper.Transfer(newContents, outStream); //if the filename is changing, assign the file a new unique filename token string fileNameUniqueToken = fileName == file.FileName ? file.FileNameUniqueToken : _fileService.CreateUniqueFileNameToken(fileName); //Clone the file so that its old version can still be referenced by its old URL. //Note: this is required since editor undo operations may allow the post to rollback //to referencing the old version of the file. VersionedSupportingFile newFile = new VersionedSupportingFile(this, _nextVersion++, new Uri(UrlHelper.CreateUrlFromPath(newStoragePath)), fileName, fileNameUniqueToken, true, (BlogPostSettingsBag)file.Settings.Clone()); ; newFile.StoragePath = newStoragePath; RegisterSupportingFile(newFile); return newFile; }
private ISupportingFile RegisterSupportingFile(VersionedSupportingFile file) { _versionTable[file.FileVersion] = file; _fileService.RegisterSupportingFile(file); return file; }