/// <summary> /// Replaces the contents of an existing object with exactly one file, with data from <paramref name="fileContents"/>. /// </summary> /// <param name="objVerEx">The object version that contains exactly one file. Must already be checked out.</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, Stream fileContents, int blockSize = FileTransfers.DefaultBlockSize ) { // Sanity. if (null == objVerEx) { throw new ArgumentNullException(nameof(objVerEx)); } if (null == objVerEx.Info?.Files) { throw new ArgumentException($"The object version does not contain information about its files.", nameof(objVerEx)); } if (null == fileContents) { throw new ArgumentNullException(nameof(fileContents)); } // Does it have exactly one file? if (1 != objVerEx.Info.FilesCount) { throw new ArgumentException($"The object version does not contain exactly one file.", nameof(objVerEx)); } // Use the other extension method. objVerEx.ReplaceFileContent ( objVerEx.Info.Files[1], fileContents, blockSize ); }