@zodic/shared 0.0.347 → 0.0.349
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/api/index.ts +6 -20
- package/package.json +1 -1
package/app/api/index.ts
CHANGED
|
@@ -839,14 +839,9 @@ export const Api = (env: BackendBindings) => ({
|
|
|
839
839
|
}
|
|
840
840
|
};
|
|
841
841
|
|
|
842
|
-
const getKey = (
|
|
843
|
-
const
|
|
844
|
-
const
|
|
845
|
-
const fileNameWithoutExtension = fileNameParts.join('.');
|
|
846
|
-
|
|
847
|
-
const newFileName = `${fileNameWithoutExtension}-${v4()}.${extension}`;
|
|
848
|
-
const key = `${newFileName.replace(/ /g, '_')}`;
|
|
849
|
-
|
|
842
|
+
const getKey = (label: string) => {
|
|
843
|
+
const timestamp = Date.now();
|
|
844
|
+
const key = `${label.toLowerCase().replace(/ /g, '_')}_${timestamp}.jpg`;
|
|
850
845
|
return key;
|
|
851
846
|
};
|
|
852
847
|
|
|
@@ -857,17 +852,8 @@ export const Api = (env: BackendBindings) => ({
|
|
|
857
852
|
): Promise<string> => {
|
|
858
853
|
const key = getKey(label);
|
|
859
854
|
await env.PHOTOS_BUCKET.put(key, imageData);
|
|
860
|
-
const imageUrl = `https://pub-
|
|
855
|
+
const imageUrl = `https://pub-bbc0cdb569734925ab1c39512bc4765d.r2.dev/${key}`;
|
|
861
856
|
return imageUrl;
|
|
862
|
-
// Replace this with your actual storage service implementation (e.g., Cloudflare R2, AWS S3)
|
|
863
|
-
// Example for Cloudflare R2:
|
|
864
|
-
// const r2Response = await env.R2_BUCKET.put(fileName, imageData, {
|
|
865
|
-
// httpMetadata: { contentType: 'image/jpeg' },
|
|
866
|
-
// });
|
|
867
|
-
// return `https://your-r2-bucket-url/${fileName}`;
|
|
868
|
-
|
|
869
|
-
// For now, we'll throw an error if this isn't implemented
|
|
870
|
-
throw new Error(`Storage service not implemented for ${label}`);
|
|
871
857
|
};
|
|
872
858
|
|
|
873
859
|
try {
|
|
@@ -888,11 +874,11 @@ export const Api = (env: BackendBindings) => ({
|
|
|
888
874
|
// Upload resized images to storage to get public URLs
|
|
889
875
|
const resizedSourceUrl = await uploadImageToStorage(
|
|
890
876
|
resizedSourceData,
|
|
891
|
-
'
|
|
877
|
+
'user_photo'
|
|
892
878
|
);
|
|
893
879
|
const resizedTargetUrl = await uploadImageToStorage(
|
|
894
880
|
resizedTargetData,
|
|
895
|
-
'
|
|
881
|
+
'generated_image'
|
|
896
882
|
);
|
|
897
883
|
|
|
898
884
|
const body = JSON.stringify({
|