/// <summary> /// Replaces the contents of an existing <paramref name="objectFile"/> with data from <paramref name="fileContents"/>. /// </summary> /// <param name="objVerEx">The object version that contains the file. Must already be checked out.</param> /// <param name="objectFile">The file to update.</param> /// <param name="fileContents">The contents of the file.</param> /// <param name="blockSize">The block size to use for transfers.</param> public static void ReplaceFileContent ( this ObjVerEx objVerEx, ObjectFile objectFile, Stream fileContents, int blockSize = FileTransfers.DefaultBlockSize ) { // Sanity. if (null == objVerEx) { throw new ArgumentNullException(nameof(objVerEx)); } if (null == objectFile) { throw new ArgumentNullException(nameof(objectFile)); } if (null == fileContents) { throw new ArgumentNullException(nameof(fileContents)); } // Use the other extension method. objectFile.ReplaceFileContent ( objVerEx.Vault, fileContents, blockSize ); }
/// <summary> /// Replaces an existing file with data from another stream. /// </summary> /// <param name="objectFile">The file to replace.</param> /// <param name="vault">The vault from in which the file exists.</param> /// <param name="input">The new content for the file.</param> /// <param name="blockSize">The block size to use.</param> /// <remarks>It is more performant to use <see cref="ReplaceFileContent(ObjectFile, Vault, ObjID, Stream, int)"/> if you already have the file ID.</remarks> public static void ReplaceFileContent ( this ObjectFile objectFile, Vault vault, Stream input, int blockSize = FileTransfers.DefaultBlockSize ) { // Sanity. if (null == objectFile) { throw new ArgumentNullException(nameof(objectFile)); } if (null == vault) { throw new ArgumentNullException(nameof(vault)); } // Attempt to get the object ID for this file. var objId = vault.ObjectFileOperations.GetObjIDOfFile(objectFile.ID); // Use the other overload. objectFile.ReplaceFileContent(vault, objId, input, blockSize); }