mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-24 15:38:10 +02:00
Fix issue with uploading camera photos on Android devices
Correct the file naming convention for camera captures on Android to prevent upload failures by generating a valid filename if the original is missing or invalid. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/fGL9Pd7
This commit is contained in:
1 parent
a04414ab46
commit
b3675a1900
2 files changed
+16
-2
No files matched your search
@@ -115,7 +115,14 @@ export default function MediaUpload() {
|
|||||||
const handleCameraCapture = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleCameraCapture = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const file = e.target.files?.[0];
|
const file = e.target.files?.[0];
|
||||||
if (file) {
|
if (file) {
|
||||||
uploadMutation.mutate(file);
|
// Correction Android : créer un nom valide si le fichier n'a pas de nom
|
||||||
|
let fileToUpload = file;
|
||||||
|
if (!file.name || file.name === 'blob' || file.name === '') {
|
||||||
|
const extension = file.type.split('/')[1] || 'jpg';
|
||||||
|
const newFileName = `camera-${Date.now()}.${extension}`;
|
||||||
|
fileToUpload = new File([file], newFileName, { type: file.type });
|
||||||
|
}
|
||||||
|
uploadMutation.mutate(fileToUpload);
|
||||||
// Réinitialiser l'input pour permettre de capturer la même photo à nouveau
|
// Réinitialiser l'input pour permettre de capturer la même photo à nouveau
|
||||||
e.target.value = '';
|
e.target.value = '';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -294,7 +294,14 @@ export default function NewPost() {
|
|||||||
const handleCameraCapture = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleCameraCapture = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const file = e.target.files?.[0];
|
const file = e.target.files?.[0];
|
||||||
if (file) {
|
if (file) {
|
||||||
uploadMutation.mutate(file);
|
// Correction Android : créer un nom valide si le fichier n'a pas de nom
|
||||||
|
let fileToUpload = file;
|
||||||
|
if (!file.name || file.name === 'blob' || file.name === '') {
|
||||||
|
const extension = file.type.split('/')[1] || 'jpg';
|
||||||
|
const newFileName = `camera-${Date.now()}.${extension}`;
|
||||||
|
fileToUpload = new File([file], newFileName, { type: file.type });
|
||||||
|
}
|
||||||
|
uploadMutation.mutate(fileToUpload);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user