My zip file has files nested in subfolders. First I used db:store to store delta.zip into the database. My first problem was I got an error " *invalid entry CRC: expected 0x0 but got..."* The raw stored file was slightly larger *than the original zip.* So I replaced the zip file in the raw folder with the original one and the first error went away. Now I don't get any error bu the extracted file are not stored as binaries
What is wrong with this code? I removed the updating annotation and returned $target instead of the try/store/catch inside the loop and got the expected result path name
let $database := 'db' let $extractTo := 'target.zip'
(: path to raw stored zip :) let $archivePath := 'alpha/bravo/charlie/delta.zip'
let $archive := db:retrieve($database, $archivePath) let $basePath := replace($archivePath, '[^/]+$', '') || $extractTo let $entries := archive:entries($archive) let $contents := archive:extract-binary($archive) return for-each-pair($entries, $contents, %updating function($entry, $content) { let $target := $basePath || '/' || $entry/text() return try { db:store($database, $target, $content) } catch * { () } })