managarten/apps-archived/presi/apps/mobile/services/storage.ts
Till-JS 44897ae758 chore: archive inventory, presi, storage apps
Move these apps to apps-archived/ as they are not actively developed:
- inventory: Inventory management app
- presi: Presentation tool
- storage: Cloud storage app

These can be reactivated by moving back to apps/ when needed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 15:22:38 +01:00

31 lines
985 B
TypeScript

import { storage } from '../firebaseConfig';
import { ref, uploadBytes, getDownloadURL } from 'firebase/storage';
export const uploadImage = async (file: Blob, path: string): Promise<string> => {
try {
const storageRef = ref(storage, path);
const metadata = {
contentType: 'image/jpeg',
cacheControl: 'public,max-age=3600',
};
const snapshot = await uploadBytes(storageRef, file, metadata);
const downloadURL = await getDownloadURL(snapshot.ref);
return downloadURL;
} catch (error) {
console.error('[Storage] Error uploading image:', error);
throw error;
}
};
export const uploadImages = async (files: Blob[], basePath: string): Promise<string[]> => {
try {
const uploadPromises = files.map((file, index) => {
const path = `${basePath}/${index}_${Date.now()}.jpg`;
return uploadImage(file, path);
});
return await Promise.all(uploadPromises);
} catch (error) {
console.error('[Storage] Error uploading images:', error);
throw error;
}
};