Closed thomasaustin closed 6 years ago
@thomasaustin As for now no.
The reason behind this is that you usually upload the archive file in a mail service. They will manage their own CDN and don't impact yours.
But the test mail button will send you the HTML with the images linked to your own CDN.
@Hiswe thanks for the response. My ESP doesn't handle the upload of a zip file with images and html at the same time. So I would have to upload the images by themselves then relink everything in the html. Is there a way to modify the download to export what the test send is producing?
The other issue is I've got assets like logos and icons etc which I would have to upload every time I create an email.
You can modify the download function on the server.
here is how the mail is send
so you almost just need to remove all the code parsing and downloading images in this function in order to look like more the send mail function :)
@Hiswe Is there a way to change the image file path on download? It's currently 'images/' but I'd like to change it to 'https://cdnurl/foldername/' as this would solve all my issues.
Would I just change 'images' on this line to 'https://cdnurl/foldername'?
@thomasaustin imagesFolder
is used for the archive's image folder name. So if you need to modify it sure :)
If you only want to download the html something like this should to:
async function zip(req, res, next) {
const { user, body } = req
const { mailingId } = req.params
const reqParams = {
where: {
id: mailingId,
},
}
const mailing = await Mailing.findOne( addGroupFilter(req, reqParams) )
if (!mailing) return next( createError(404) )
const archive = archiver( 'zip' )
let { html } = body
let name = getName( mailing.name )
console.log('download zip', name)
archive.on( 'error', next )
// on stream closed we can end the request
archive.on( 'end', () => {
console.log( 'Archive wrote %d bytes', archive.pointer() )
res.end()
})
// set the archive name
res.attachment( `${name}.zip` )
// this is the streaming magic
archive.pipe( res )
// Add html with relatives url
archive.append(secureHtml(html), {
name: `${name}.html`,
})
archive.finalize()
}
@Hiswe Thanks for your help! I modified the file path name and all seems to be working.
When you download the final result is there a way to keep the image urls remote?