Hello to Everyone!
I’m trying to use the function to move an image to the mediaManager trash with a button that can be used by a registered user.
The code seems easy to me, but it doesn’t work. Considering that many other developers may have this need of mine, can you please help me? I report the code below.
Thanks !
note
I used a url copied directly from mediaManager to be sure about the address, while tested the function, later I would get it with a query
code into a event.jsw file (backend)
import { mediaManager } from ‘wix-media-backend’ ;
export function moveTrash ( fileUrls ) {
return mediaManager . moveFilesToTrash ( fileUrls )
. then (() => {
console . log ( ‘Success! Files have been trashed.’ );
})
. catch (( error ) => {
console . error ( error );
})
}
code into the page
import { moveTrash } from ‘backend/event.jsw’
$w . onReady ( function () {})
export function button1_click ( event ) {
let dbUrl = https://static.wixstatic.com/media/f9c7a0_682bdb1feb274cb1b0aec3448e6f42d4~mv2.jpeg’
moveTrash( dbUrl ). then (() => { $w ( “#text1” ). text = “YEAH!” })
}