curl -X GET "https://api.tktchurch.com/v1/files/123e4567-e89b-12d3-a456-426614174000" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..."
const getFile = async (accessToken, id) => {
const response = await fetch(
`https://api.tktchurch.com/v1/files/${id}`,
{
headers: {
'Authorization': `Bearer ${accessToken}`
}
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.reason || 'Failed to get file');
}
return response.json();
};
// Usage
try {
const file = await getFile(
'eyJhbGciOiJIUzI1NiIs...',
'123e4567-e89b-12d3-a456-426614174000'
);
console.log('File:', file);
} catch (error) {
console.error('Error:', error.message);
}
func getFile(accessToken: String, id: UUID) async throws -> File {
var urlRequest = URLRequest(url: URL(string: "https://api.tktchurch.com/v1/files/\(id)")!)
urlRequest.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")
let (data, response) = try await URLSession.shared.data(for: urlRequest)
guard let httpResponse = response as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
if httpResponse.statusCode == 404 {
throw URLError(.resourceNotFound)
}
if httpResponse.statusCode != 200 {
throw URLError(.badServerResponse)
}
return try JSONDecoder().decode(File.self, from: data)
}
// Usage
do {
let file = try await getFile(
accessToken: "eyJhbGciOiJIUzI1NiIs...",
id: UUID(uuidString: "123e4567-e89b-12d3-a456-426614174000")!
)
print("File:", file)
} catch {
print("Error:", error)
}
suspend fun getFile(accessToken: String, id: UUID): File {
val request = Request.Builder()
.url("https://api.tktchurch.com/v1/files/$id")
.get()
.header("Authorization", "Bearer $accessToken")
.build()
return withContext(Dispatchers.IO) {
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) {
throw when (response.code) {
404 -> NoSuchElementException("File not found")
else -> IOException("Unexpected response ${response.code}")
}
}
val body = response.body?.string() ?: throw IOException("Empty response")
Json.decodeFromString<File>(body)
}
}
}
// Usage
try {
val file = getFile(
"eyJhbGciOiJIUzI1NiIs...",
UUID.fromString("123e4567-e89b-12d3-a456-426614174000")
)
println("File: $file")
} catch (e: Exception) {
println("Error: ${e.message}")
}
const getFile = async (accessToken: string, id: string): Promise<File> => {
try {
const response = await axios.get<File>(
`https://api.tktchurch.com/v1/files/${id}`,
{
headers: {
'Authorization': `Bearer ${accessToken}`
},
}
);
return response.data;
} catch (error) {
if (axios.isAxiosError(error)) {
if (error.response?.status === 404) {
throw new Error('File not found');
}
throw new Error(error.response?.data?.reason || 'Failed to get file');
}
throw error;
}
};
// Usage
try {
const file = await getFile(
'eyJhbGciOiJIUzI1NiIs...',
'123e4567-e89b-12d3-a456-426614174000'
);
console.log('File:', file);
} catch (error) {
console.error('Error:', error.message);
}
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"originalName": "example.jpg",
"url": "https://storage.example.com/uploads/abc123.jpg",
"key": "uploads/abc123.jpg",
"contentType": "image/jpeg",
"size": 1048576,
"provider": "s3",
"providerMetadata": {
"bucket": "my-bucket",
"region": "us-east-1"
},
"uploadedBy": "123e4567-e89b-12d3-a456-426614174001",
"createdAt": "2024-01-20T15:00:00Z",
"updatedAt": "2024-01-20T15:00:00Z"
}
{
"error": {
"status": 401,
"reason": "Invalid or expired access token"
}
}
{
"error": {
"status": 404,
"reason": "File not found"
}
}
Files
Get File
Get metadata for a specific file
GET
/
files
/
{id}
curl -X GET "https://api.tktchurch.com/v1/files/123e4567-e89b-12d3-a456-426614174000" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..."
const getFile = async (accessToken, id) => {
const response = await fetch(
`https://api.tktchurch.com/v1/files/${id}`,
{
headers: {
'Authorization': `Bearer ${accessToken}`
}
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.reason || 'Failed to get file');
}
return response.json();
};
// Usage
try {
const file = await getFile(
'eyJhbGciOiJIUzI1NiIs...',
'123e4567-e89b-12d3-a456-426614174000'
);
console.log('File:', file);
} catch (error) {
console.error('Error:', error.message);
}
func getFile(accessToken: String, id: UUID) async throws -> File {
var urlRequest = URLRequest(url: URL(string: "https://api.tktchurch.com/v1/files/\(id)")!)
urlRequest.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")
let (data, response) = try await URLSession.shared.data(for: urlRequest)
guard let httpResponse = response as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
if httpResponse.statusCode == 404 {
throw URLError(.resourceNotFound)
}
if httpResponse.statusCode != 200 {
throw URLError(.badServerResponse)
}
return try JSONDecoder().decode(File.self, from: data)
}
// Usage
do {
let file = try await getFile(
accessToken: "eyJhbGciOiJIUzI1NiIs...",
id: UUID(uuidString: "123e4567-e89b-12d3-a456-426614174000")!
)
print("File:", file)
} catch {
print("Error:", error)
}
suspend fun getFile(accessToken: String, id: UUID): File {
val request = Request.Builder()
.url("https://api.tktchurch.com/v1/files/$id")
.get()
.header("Authorization", "Bearer $accessToken")
.build()
return withContext(Dispatchers.IO) {
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) {
throw when (response.code) {
404 -> NoSuchElementException("File not found")
else -> IOException("Unexpected response ${response.code}")
}
}
val body = response.body?.string() ?: throw IOException("Empty response")
Json.decodeFromString<File>(body)
}
}
}
// Usage
try {
val file = getFile(
"eyJhbGciOiJIUzI1NiIs...",
UUID.fromString("123e4567-e89b-12d3-a456-426614174000")
)
println("File: $file")
} catch (e: Exception) {
println("Error: ${e.message}")
}
const getFile = async (accessToken: string, id: string): Promise<File> => {
try {
const response = await axios.get<File>(
`https://api.tktchurch.com/v1/files/${id}`,
{
headers: {
'Authorization': `Bearer ${accessToken}`
},
}
);
return response.data;
} catch (error) {
if (axios.isAxiosError(error)) {
if (error.response?.status === 404) {
throw new Error('File not found');
}
throw new Error(error.response?.data?.reason || 'Failed to get file');
}
throw error;
}
};
// Usage
try {
const file = await getFile(
'eyJhbGciOiJIUzI1NiIs...',
'123e4567-e89b-12d3-a456-426614174000'
);
console.log('File:', file);
} catch (error) {
console.error('Error:', error.message);
}
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"originalName": "example.jpg",
"url": "https://storage.example.com/uploads/abc123.jpg",
"key": "uploads/abc123.jpg",
"contentType": "image/jpeg",
"size": 1048576,
"provider": "s3",
"providerMetadata": {
"bucket": "my-bucket",
"region": "us-east-1"
},
"uploadedBy": "123e4567-e89b-12d3-a456-426614174001",
"createdAt": "2024-01-20T15:00:00Z",
"updatedAt": "2024-01-20T15:00:00Z"
}
{
"error": {
"status": 401,
"reason": "Invalid or expired access token"
}
}
{
"error": {
"status": 404,
"reason": "File not found"
}
}
This endpoint requires authentication.
Path Parameters
string
required
The UUID of the file to retrieve
Response
string
File’s unique identifier (UUID)
string
Original filename
string
URL to access the file
string
Storage key/path of the file
string
MIME type of the file
integer
File size in bytes
string
Storage provider used (s3 or local)
object
Provider-specific metadata
string
UUID of the user who uploaded the file
string
Upload timestamp in ISO 8601 format
string
Last update timestamp in ISO 8601 format
Error Responses
object
Common error cases:
- 401 Unauthorized: Missing or invalid access token
- 404 Not Found: File not found
curl -X GET "https://api.tktchurch.com/v1/files/123e4567-e89b-12d3-a456-426614174000" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..."
const getFile = async (accessToken, id) => {
const response = await fetch(
`https://api.tktchurch.com/v1/files/${id}`,
{
headers: {
'Authorization': `Bearer ${accessToken}`
}
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.reason || 'Failed to get file');
}
return response.json();
};
// Usage
try {
const file = await getFile(
'eyJhbGciOiJIUzI1NiIs...',
'123e4567-e89b-12d3-a456-426614174000'
);
console.log('File:', file);
} catch (error) {
console.error('Error:', error.message);
}
func getFile(accessToken: String, id: UUID) async throws -> File {
var urlRequest = URLRequest(url: URL(string: "https://api.tktchurch.com/v1/files/\(id)")!)
urlRequest.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")
let (data, response) = try await URLSession.shared.data(for: urlRequest)
guard let httpResponse = response as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
if httpResponse.statusCode == 404 {
throw URLError(.resourceNotFound)
}
if httpResponse.statusCode != 200 {
throw URLError(.badServerResponse)
}
return try JSONDecoder().decode(File.self, from: data)
}
// Usage
do {
let file = try await getFile(
accessToken: "eyJhbGciOiJIUzI1NiIs...",
id: UUID(uuidString: "123e4567-e89b-12d3-a456-426614174000")!
)
print("File:", file)
} catch {
print("Error:", error)
}
suspend fun getFile(accessToken: String, id: UUID): File {
val request = Request.Builder()
.url("https://api.tktchurch.com/v1/files/$id")
.get()
.header("Authorization", "Bearer $accessToken")
.build()
return withContext(Dispatchers.IO) {
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) {
throw when (response.code) {
404 -> NoSuchElementException("File not found")
else -> IOException("Unexpected response ${response.code}")
}
}
val body = response.body?.string() ?: throw IOException("Empty response")
Json.decodeFromString<File>(body)
}
}
}
// Usage
try {
val file = getFile(
"eyJhbGciOiJIUzI1NiIs...",
UUID.fromString("123e4567-e89b-12d3-a456-426614174000")
)
println("File: $file")
} catch (e: Exception) {
println("Error: ${e.message}")
}
const getFile = async (accessToken: string, id: string): Promise<File> => {
try {
const response = await axios.get<File>(
`https://api.tktchurch.com/v1/files/${id}`,
{
headers: {
'Authorization': `Bearer ${accessToken}`
},
}
);
return response.data;
} catch (error) {
if (axios.isAxiosError(error)) {
if (error.response?.status === 404) {
throw new Error('File not found');
}
throw new Error(error.response?.data?.reason || 'Failed to get file');
}
throw error;
}
};
// Usage
try {
const file = await getFile(
'eyJhbGciOiJIUzI1NiIs...',
'123e4567-e89b-12d3-a456-426614174000'
);
console.log('File:', file);
} catch (error) {
console.error('Error:', error.message);
}
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"originalName": "example.jpg",
"url": "https://storage.example.com/uploads/abc123.jpg",
"key": "uploads/abc123.jpg",
"contentType": "image/jpeg",
"size": 1048576,
"provider": "s3",
"providerMetadata": {
"bucket": "my-bucket",
"region": "us-east-1"
},
"uploadedBy": "123e4567-e89b-12d3-a456-426614174001",
"createdAt": "2024-01-20T15:00:00Z",
"updatedAt": "2024-01-20T15:00:00Z"
}
{
"error": {
"status": 401,
"reason": "Invalid or expired access token"
}
}
{
"error": {
"status": 404,
"reason": "File not found"
}
}
