chore: update code structure for improved readability and maintainability
This commit is contained in:
@@ -221,4 +221,30 @@ async function stopCamera(id){
|
||||
alert("Error stopping the camera :", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function manualUpload(imageFile, projectId, timestamp, temperature, humidity) {
|
||||
try {
|
||||
// Create FormData to send the file and metadata
|
||||
const formData = new FormData();
|
||||
formData.append('image', imageFile);
|
||||
formData.append('projectId', projectId);
|
||||
formData.append('timestamp', timestamp);
|
||||
formData.append('temperature', temperature);
|
||||
formData.append('humidity', humidity);
|
||||
|
||||
const response = await $.ajax({
|
||||
url: api_url.concat("/camera/upload"),
|
||||
method: "POST",
|
||||
data: formData,
|
||||
processData: false, // Prevents jQuery from converting FormData to string
|
||||
contentType: false, // Lets browser set the content type with boundary
|
||||
});
|
||||
|
||||
alert("Image uploaded successfully");
|
||||
return response;
|
||||
} catch (error) {
|
||||
alert("Error uploading image: " + error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user