|
|
@@ -109,36 +109,37 @@ export function useImages(bucket: string = PUBLIC_BUCKET) {
|
|
|
|
|
|
if (uploadError) throw uploadError;
|
|
|
|
|
|
- // Register with image API for short URL and tracking using SDK
|
|
|
- const sessionToken = getSessionToken();
|
|
|
- const apiResponse = await client.request<{ short_code: string }>(
|
|
|
- '/api/images',
|
|
|
- {
|
|
|
- method: 'POST',
|
|
|
- headers: { 'X-Session-Token': sessionToken },
|
|
|
- body: JSON.stringify({
|
|
|
- bucket,
|
|
|
- path,
|
|
|
- storage_object_id: data?.id,
|
|
|
- download_allowed: options.downloadAllowed,
|
|
|
- expires_at: expiresAt,
|
|
|
- }),
|
|
|
- }
|
|
|
- );
|
|
|
-
|
|
|
let shortCode: string | undefined;
|
|
|
let shortUrl: string | undefined;
|
|
|
|
|
|
- if (!apiResponse.error && apiResponse.data) {
|
|
|
- shortCode = apiResponse.data.short_code;
|
|
|
- shortUrl = `/i/${shortCode}`;
|
|
|
+ // Only register with image API for anonymous users (auto short link generation)
|
|
|
+ // Logged-in users manage share links manually via the dashboard
|
|
|
+ if (!isAuthenticated) {
|
|
|
+ const sessionToken = getSessionToken();
|
|
|
+ const apiResponse = await client.request<{ short_code: string }>(
|
|
|
+ '/api/images',
|
|
|
+ {
|
|
|
+ method: 'POST',
|
|
|
+ headers: { 'X-Session-Token': sessionToken },
|
|
|
+ body: JSON.stringify({
|
|
|
+ bucket,
|
|
|
+ path,
|
|
|
+ storage_object_id: data?.id,
|
|
|
+ download_allowed: options.downloadAllowed,
|
|
|
+ expires_at: expiresAt,
|
|
|
+ }),
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ if (!apiResponse.error && apiResponse.data) {
|
|
|
+ shortCode = apiResponse.data.short_code;
|
|
|
+ shortUrl = `/i/${shortCode}`;
|
|
|
|
|
|
- // Track anonymous uploads for deletion capability
|
|
|
- if (!isAuthenticated && shortCode) {
|
|
|
+ // Track anonymous uploads for deletion capability
|
|
|
trackUpload(shortCode);
|
|
|
+ } else {
|
|
|
+ console.warn('Failed to register image with API:', apiResponse.error);
|
|
|
}
|
|
|
- } else {
|
|
|
- console.warn('Failed to register image with API:', apiResponse.error);
|
|
|
}
|
|
|
|
|
|
const newImage: ImageFile = {
|