diff --git a/src/Testcontainers/Clients/ITestcontainersClient.cs b/src/Testcontainers/Clients/ITestcontainersClient.cs index 493588987..b388b872a 100644 --- a/src/Testcontainers/Clients/ITestcontainersClient.cs +++ b/src/Testcontainers/Clients/ITestcontainersClient.cs @@ -135,19 +135,6 @@ internal interface ITestcontainersClient /// A task that completes when the file has been copied. Task CopyAsync(string id, FileInfo source, string target, UnixFileModes fileMode, CancellationToken ct = default); - /// - /// Copies a file to the container. - /// - /// The container id. - /// The path to the file in the container. - /// The content of the file as bytes. - /// The access mode for the file. - /// The owner of the file. - /// The group of the file. - /// Cancellation token. - /// Task that completes when the file has been copied. - Task CopyFileAsync(string id, string filePath, byte[] fileContent, int accessMode, int userId, int groupId, CancellationToken ct = default); - /// /// Reads a file from the container. /// diff --git a/src/Testcontainers/Clients/TestcontainersClient.cs b/src/Testcontainers/Clients/TestcontainersClient.cs index d474e1df9..21f9ffe6c 100644 --- a/src/Testcontainers/Clients/TestcontainersClient.cs +++ b/src/Testcontainers/Clients/TestcontainersClient.cs @@ -226,48 +226,6 @@ await Container.ExtractArchiveToContainerAsync(id, "/", tarOutputMemStream, ct) } } - /// - public async Task CopyFileAsync(string id, string filePath, byte[] fileContent, int accessMode, int userId, int groupId, CancellationToken ct = default) - { - var containerPath = Unix.Instance.NormalizePath(filePath); - - using (var tarOutputMemStream = new MemoryStream()) - { - using (var tarOutputStream = new TarOutputStream(tarOutputMemStream, Encoding.Default)) - { - tarOutputStream.IsStreamOwner = false; - - var header = new TarHeader(); - header.Name = containerPath; - header.UserId = userId; - header.GroupId = groupId; - header.Mode = accessMode; - header.Size = fileContent.Length; - - var entry = new TarEntry(header); - - await tarOutputStream.PutNextEntryAsync(entry, ct) - .ConfigureAwait(false); - -#if NETSTANDARD2_1_OR_GREATER - await tarOutputStream.WriteAsync(fileContent, ct) - .ConfigureAwait(false); -#else - await tarOutputStream.WriteAsync(fileContent, 0, fileContent.Length, ct) - .ConfigureAwait(false); -#endif - - await tarOutputStream.CloseEntryAsync(ct) - .ConfigureAwait(false); - } - - tarOutputMemStream.Seek(0, SeekOrigin.Begin); - - await Container.ExtractArchiveToContainerAsync(id, "/", tarOutputMemStream, ct) - .ConfigureAwait(false); - } - } - /// public async Task ReadFileAsync(string id, string filePath, CancellationToken ct = default) { diff --git a/src/Testcontainers/Containers/DockerContainer.cs b/src/Testcontainers/Containers/DockerContainer.cs index 69dbd2526..1d36df8e8 100644 --- a/src/Testcontainers/Containers/DockerContainer.cs +++ b/src/Testcontainers/Containers/DockerContainer.cs @@ -312,12 +312,6 @@ public Task CopyAsync(DirectoryInfo source, string target, UnixFileModes fileMod return _client.CopyAsync(Id, source, target, fileMode, ct); } - /// - public Task CopyFileAsync(string filePath, byte[] fileContent, int accessMode = 384, int userId = 0, int groupId = 0, CancellationToken ct = default) - { - return _client.CopyFileAsync(Id, filePath, fileContent, accessMode, userId, groupId, ct); - } - /// public Task ReadFileAsync(string filePath, CancellationToken ct = default) { diff --git a/src/Testcontainers/Containers/IContainer.cs b/src/Testcontainers/Containers/IContainer.cs index a539f469b..211a2dac2 100644 --- a/src/Testcontainers/Containers/IContainer.cs +++ b/src/Testcontainers/Containers/IContainer.cs @@ -206,27 +206,6 @@ public interface IContainer : IAsyncDisposable /// A task that completes when the file has been copied. Task CopyAsync(FileInfo source, string target, UnixFileModes fileMode = Unix.FileMode644, CancellationToken ct = default); - /// - /// Copies a file to the container. - /// - /// An absolute path as destination in the container. - /// The byte array content of the file. - /// The access mode for the file (default: 0600). - /// The owner of the file. - /// The group of the file. - /// Cancellation token. - /// Task that completes when the file has been copied. - /// - /// is a decimal value. Covert chmod (octal) to decimal. - ///
    - ///
  • 777 octal 🠒 111_111_111 binary 🠒 511 decimal
  • - ///
  • 755 octal 🠒 111_101_101 binary 🠒 493 decimal
  • - ///
  • 644 octal 🠒 110_100_100 binary 🠒 420 decimal
  • - ///
- ///
- [Obsolete("Use CopyAsync(byte[], string, UnixFileMode, CancellationToken) or one of its overloads.")] - Task CopyFileAsync(string filePath, byte[] fileContent, int accessMode = 384, int userId = 0, int groupId = 0, CancellationToken ct = default); - /// /// Reads a file from the container. ///