update context image should be text
All checks were successful
Deploy to Production / deploy (push) Successful in 20s
All checks were successful
Deploy to Production / deploy (push) Successful in 20s
This commit is contained in:
@@ -228,10 +228,10 @@ class ContextController {
|
||||
const { id } = req.params;
|
||||
const { image } = req.body;
|
||||
|
||||
if (!image || !Array.isArray(image) || image.length === 0) {
|
||||
if (!image || typeof image !== 'string' || image.trim().length === 0) {
|
||||
return res.status(400).json({
|
||||
success: false,
|
||||
message: 'Image must be a non-empty array of URLs'
|
||||
message: 'Image must be a non-empty string (URL)'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ const Context = sequelize.define('Context', {
|
||||
},
|
||||
image: {
|
||||
type: DataTypes.TEXT,
|
||||
comment: 'Array of image URLs'
|
||||
comment: 'Single image URL string'
|
||||
},
|
||||
type_context: {
|
||||
type: DataTypes.STRING(50),
|
||||
|
||||
@@ -402,9 +402,9 @@
|
||||
<input type="text" id="imagesUuid" placeholder="Paste UUID or click from list above">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Image URLs * (JSON Array)</label>
|
||||
<textarea id="imageUrls" placeholder='["https://example.com/image1.jpg", "https://example.com/image2.jpg"]'></textarea>
|
||||
<div class="small-note">Must be valid JSON array of URLs</div>
|
||||
<label>Image URL * (String)</label>
|
||||
<input type="text" id="imageUrls" placeholder="https://example.com/image.jpg">
|
||||
<div class="small-note">Enter a single image URL</div>
|
||||
</div>
|
||||
<button onclick="addImages()">Add Images (Status 3 → 4)</button>
|
||||
<div class="result" id="imagesResult"></div>
|
||||
@@ -647,22 +647,18 @@
|
||||
const headers = getHeaders();
|
||||
|
||||
const uuid = document.getElementById('imagesUuid').value.trim();
|
||||
const imageUrlsStr = document.getElementById('imageUrls').value.trim();
|
||||
const imageUrl = document.getElementById('imageUrls').value.trim();
|
||||
|
||||
if (!uuid || !imageUrlsStr) {
|
||||
showResult('imagesResult', { error: 'UUID and image URLs are required' }, false);
|
||||
if (!uuid || !imageUrl) {
|
||||
showResult('imagesResult', { error: 'UUID and image URL are required' }, false);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const image = JSON.parse(imageUrlsStr);
|
||||
if (!Array.isArray(image)) {
|
||||
throw new Error('Image URLs must be an array');
|
||||
}
|
||||
const response = await fetch(`${API_BASE}/${uuid}/add-images`, {
|
||||
method: 'POST',
|
||||
headers: headers,
|
||||
body: JSON.stringify({ image })
|
||||
body: JSON.stringify({ image: imageUrl })
|
||||
});
|
||||
const data = await response.json();
|
||||
showResult('imagesResult', data, response.ok);
|
||||
|
||||
Reference in New Issue
Block a user