modxbot / migrate

A testground for migrating issues and other such fun
0 stars 0 forks source link

Added makeDownload() method to modFileHandler class #10277

Open exside opened 10 years ago

exside commented 10 years ago

exside created Redmine issue ID 10277

This comes handy when a file should be sent to the user as a download instead of saving it into the filesystem.

Usage:

    $this->modx->getService('file','modFileHandler');
    // create the file object and do something with it
    $fileobj = $this->modx->file->make($this->modx->getOption('assets_path') . 'filename.ext');
    if ( !$fileobj->setContent($data) ) {
        $this->modx->log(modX::LOG_LEVEL_ERROR, '[modFileHandler] file could not be written at ' . $fileobj->getPath());
    } else {
        $this->modx->log(modX::LOG_LEVEL_ERROR, '[modFileHandler] written at ' . $fileobj->getPath());
    }
    return $fileobj->makeDownload();
exside commented 10 years ago

exside submitted:

PR submitted: https://github.com/modxcms/revolution/pull/680