From f8f2563a9249af017d6b5e38a6f5cb557e883a8e Mon Sep 17 00:00:00 2001 From: Guilherme Souza Date: Tue, 27 Aug 2024 08:07:13 -0300 Subject: [PATCH] info method calls authenticated endpoint --- Sources/Storage/StorageFileApi.swift | 18 ++++++------- .../StorageFileIntegrationTests.swift | 26 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Sources/Storage/StorageFileApi.swift b/Sources/Storage/StorageFileApi.swift index 1fe5e2ef..c0dfc687 100644 --- a/Sources/Storage/StorageFileApi.swift +++ b/Sources/Storage/StorageFileApi.swift @@ -422,15 +422,15 @@ public class StorageFileApi: StorageApi, @unchecked Sendable { } /// Retrieves the details of an existing file. -// public func info(path: String) async throws -> FileObjectV2 { -// try await execute( -// HTTPRequest( -// url: configuration.url.appendingPathComponent("object/info/public/\(bucketId)/\(path)"), -// method: .get -// ) -// ) -// .decoded(decoder: configuration.decoder) -// } + public func info(path: String) async throws -> FileObjectV2 { + try await execute( + HTTPRequest( + url: configuration.url.appendingPathComponent("object/info/authenticated/\(bucketId)/\(path)"), + method: .get + ) + ) + .decoded(decoder: configuration.decoder) + } /// Checks the existence of file. public func exists(path: String) async throws -> Bool { diff --git a/Tests/IntegrationTests/StorageFileIntegrationTests.swift b/Tests/IntegrationTests/StorageFileIntegrationTests.swift index 5816696b..f2ae953e 100644 --- a/Tests/IntegrationTests/StorageFileIntegrationTests.swift +++ b/Tests/IntegrationTests/StorageFileIntegrationTests.swift @@ -329,19 +329,19 @@ final class StorageFileIntegrationTests: XCTestCase { } } -// func testInfo() async throws { -// try await storage.from(bucketName).upload( -// uploadPath, -// data: file, -// options: FileOptions( -// metadata: ["value": 42] -// ) -// ) -// -// let info = try await storage.from(bucketName).info(path: uploadPath) -// XCTAssertEqual(info.name, uploadPath) -// XCTAssertEqual(info.metadata, ["value": 42]) -// } + func testInfo() async throws { + try await storage.from(bucketName).upload( + uploadPath, + data: file, + options: FileOptions( + metadata: ["value": 42] + ) + ) + + let info = try await storage.from(bucketName).info(path: uploadPath) + XCTAssertEqual(info.name, uploadPath) + XCTAssertEqual(info.metadata, ["value": 42]) + } func testExists() async throws { try await storage.from(bucketName).upload(uploadPath, data: file)