Appearance
useExternalShareApi Composable ​
File Information ​
- Path:
app/composables/api/useExternalShareApi.ts - Purpose: External share link API operations (public/unauthenticated)
- Category: API Composable
Overview ​
The useExternalShareApi composable provides API operations for external share links that don't require authentication. These endpoints are used for public sharing functionality where users can access shared assets without logging in.
Functions ​
getExternalShareAssets ​
Fetches external shared assets by type and status.
Signature:
typescript
getExternalShareAssets(type: string, status: string): Promise<any>Parameters:
type: string- Asset type filterstatus: string- Share status filter
Returns:
Promise<any>- External shared assets list
Features:
- No Authentication Required: Uses
skipAuth: true - Public endpoint for viewing shared assets
Usage:
typescript
const { getExternalShareAssets } = useExternalShareApi()
// Get shared assets by type and status
const assets = await getExternalShareAssets('image', 'active')API Endpoint: GET /show-share-assets?type={type}&status={status}
postShareLinkView ​
Records a share link view (analytics/tracking).
Signature:
typescript
postShareLinkView(body: any): Promise<any>Parameters:
body: any- View tracking data (typically includes share link ID, viewer info, etc.)
Returns:
Promise<any>- Response data
Features:
- No Authentication Required: Uses
skipAuth: true - Tracks share link views for analytics
Usage:
typescript
const { postShareLinkView } = useExternalShareApi()
// Track share link view
await postShareLinkView({
share_link_id: 'link-123',
viewer_ip: '192.168.1.1',
timestamp: new Date().toISOString()
})API Endpoint: POST /share-link-view
getExternalSharedFolder ​
Fetches external shared folder contents with category.
Signature:
typescript
getExternalSharedFolder(body: any): Promise<any>Parameters:
body: any- Folder request data (typically includes share token, folder ID, etc.)
Returns:
Promise<any>- Shared folder contents with categories
Features:
- No Authentication Required: Uses
skipAuth: true - Returns folder contents organized by category
Usage:
typescript
const { getExternalSharedFolder } = useExternalShareApi()
// Get shared folder contents
const folder = await getExternalSharedFolder({
share_token: 'token-123',
folder_id: 'folder-456',
category: 'all'
})API Endpoint: POST /view-share-files-with-category
Authentication ​
All functions in this composable use skipAuth: true:
typescript
const response = await $api<any>(endpoint, {
method: 'GET',
skipAuth: true, // No authentication required
})This allows:
- Public access to shared content
- No authentication token required
- Works for unauthenticated users
Complete Usage Example ​
typescript
const {
getExternalShareAssets,
postShareLinkView,
getExternalSharedFolder
} = useExternalShareApi()
// Fetch shared assets
const assets = await getExternalShareAssets('image', 'active')
// Track view
await postShareLinkView({
share_link_id: shareLinkId,
asset_id: assetId
})
// Get shared folder
const folder = await getExternalSharedFolder({
share_token: token,
folder_id: folderId
})Error Handling ​
All functions include error handling:
typescript
catch (error: any) {
console.error('[ShareAPI] fetchShareUrlsApi - Error:', error)
throw error
}Use Cases ​
Public Share Page ​
typescript
const { getExternalShareAssets } = useExternalShareApi()
// On public share page
const route = useRoute()
const type = route.query.type || 'all'
const status = route.query.status || 'active'
const assets = await getExternalShareAssets(type, status)Share Link Analytics ​
typescript
const { postShareLinkView } = useExternalShareApi()
// Track when user views shared asset
onMounted(async () => {
await postShareLinkView({
share_link_id: shareLinkId,
viewed_at: new Date().toISOString()
})
})Shared Folder Viewer ​
typescript
const { getExternalSharedFolder } = useExternalShareApi()
// Load shared folder contents
const loadFolder = async (token: string, folderId: string) => {
const folder = await getExternalSharedFolder({
share_token: token,
folder_id: folderId
})
return folder
}Related Documentation ​
- Sharing Feature - Sharing functionality
- Sharing API - Authenticated sharing API
- API Composables - Other API composables