I have a data collection with images and booleans (i want to create a filterable gallery eventually).
Right now if i want to add items, i need to add each image individualy and sparately - to click to add a new item, choose the image from my uploads, add it, move to the next item and so on.
I need to upload many images. Is there a way to upload many items (that’s many images) to this database? I want to upload many images at once and have them as separate items in this database.
Hey Dima, thanks for your reply.
I’ve been looking for a while, and didn’t find any solution.
In the links you provided there are 2 cases of user (site visitor) upload (not what i want), and one case that seems to be similar to mine, with no answer.
This seems like a basic functionality to me, i was guessing there’s a simple solution, but i didn’t find anything to solve this at all yet.
That wasn’t very helpful at all;
The first link provided was even closed without answer. The others are not relevant.
I’m afraid the correct answer to the question is:
You can not.
I have migrated a large set of images from another server by attaching a beforeInsert hook on my collection where I wanted the records with images , by using a piece of code like this:
(Unfortunately rp is a deprecated npm package, so you’ll need to find an alternative to make the request)
export async function myCollectionWithImages_beforeInsert(item, context) {
var url = item.fieldWithImageURL; //image URL
var filename = item.Title; // name of image
var response = await rp.get({ url, encoding: null }); //GET image from URL
var mediaOptions = {
"mediaOptions": {
"mimeType": "image/png",
"mediaType": "image"
}
};
var fileInfo = await mediaManager.upload("/MyUploadedImages", response, filename, mediaOptions); //upload to wix media
item.image= fileInfo.fileUrl; //set internal wix-media-URL in image field
return item;
}