Skip to content

Commit

Permalink
info method calls authenticated endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
grdsdev committed Aug 29, 2024
1 parent 1c5b00d commit 36076e3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
18 changes: 9 additions & 9 deletions Sources/Storage/StorageFileApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
26 changes: 13 additions & 13 deletions Tests/IntegrationTests/StorageFileIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 36076e3

Please sign in to comment.