Action for downloading the file
336574
public function downloadAction()
    {
        $model = $this->getModel();
        $model->applyRequest($this->getRequest());

        $fileData = $model->loadFirst();

        header('Content-Type: application/x-download');
        header('Content-Length: '.$fileData['size']);
        header('Content-Disposition: inline; filename="'.$fileData['filename'].'"');
        header('Pragma: public');

        echo $fileData['content'];
        exit();
    }
1098287
function httpDownload(targetPath, path, file)  {
    switch (configuredDownloadClient) {
        case "curl": return sh`curl -A curl --progress -o "${targetPath}/${file}" "https://transfer.sh/${path}/${file}"`;
        case "wget": return sh`wget --progress=dot -O "${targetPath}/${file}" "https://transfer.sh/${path}/${file}"`;
        case "fetch": return sh`fetch -q -o "${targetPath}/${file}" "https://transfer.sh/${path}/${file}"`;
        default: throw new Error("No configured download client");
    }
}
650940
def download(self, url, file):
        
        if isinstance(file, str) or isinstance(file, unicode):
            file = open(file, 'wb')
        webclient = self.dupe()
        webclient.request('GET', url)
        rsp = webclient.getresponse()
        self._currdl = rsp
        self._dlfile = file
        for chunk in iter(lambda: rsp.read(16384), ''):
            file.write(chunk)
        self._currdl = None
        file.close()
200575
def do_file_show(client, args):
    """"""
    for src_uri in args.uris:
        client.download_file(src_uri, sys.stdout.buffer)

    return True
584296
def download(url, max_size: nil, progress_proc: nil, content_length_proc: nil, destination: nil, **options, &block)
      response = request(url, **options, &block)

      content_length_proc.call(response.content_length) if content_length_proc && response.content_length

      if max_size && response.content_length && response.content_length > max_size
        raise Down::TooLarge, "file is too large (max is #{max_size/1024/1024}MB)"
      end

      extname  = File.extname(response.uri.path)
      tempfile = Tempfile.new(["down-http", extname], binmode: true)

      stream_body(response) do |chunk|
        tempfile.write(chunk)
        chunk.clear # deallocate string

        progress_proc.call(tempfile.size) if progress_proc

        if max_size && tempfile.size > max_size
          raise Down::TooLarge, "file is too large (max is #{max_size/1024/1024}MB)"
        end
      end

      tempfile.open # flush written content

      tempfile.extend Down::Http::DownloadedFile
      tempfile.url     = response.uri.to_s
      tempfile.headers = response.headers.to_h

      download_result(tempfile, destination)
    rescue
      tempfile.close! if tempfile
      raise
    end
195719
def action_download(self, courseid, taskid, path):
        

        wanted_path = self.verify_path(courseid, taskid, path)
        if wanted_path is None:
            raise web.notfound()

        task_fs = self.task_factory.get_task_fs(courseid, taskid)
        (method, mimetype_or_none, file_or_url) = task_fs.distribute(wanted_path)

        if method == "local":
            web.header('Content-Type', mimetype_or_none)
            return file_or_url
        elif method == "url":
            raise web.redirect(file_or_url)
        else:
            raise web.notfound()
404461
def download(self, request, **kwargs):
        '''
        
        '''
        # method check to avoid bad requests
        self.method_check(request, allowed=['get'])
        # Must be done otherwise endpoint will be wide open
        self.is_authenticated(request)

        response = None
        file_item_name = kwargs.get('name', None)
        if file_item_name:
            filename_absolute = helpers.get_filename_absolute(file_item_name)
            if os.path.isfile(filename_absolute):
                response = serve(request, os.path.basename(filename_absolute), os.path.dirname(filename_absolute))
                response['Content-Disposition'] = 'attachment; filename="{}"'.format(
                    os.path.basename(filename_absolute))

        if not response:
            response = self.create_response(request, {'status': 'filename not specified'})

        return response
468328
function handleSafeToDownload() {
        var downloadFn = function () {
            if (isFirstIterationDownload()) {
                // For the first iteration of download, show download
                //status info in Status bar, and pass download to node
                UpdateStatus.showUpdateStatus("initial-download");
                postMessageToNode(MessageIds.DOWNLOAD_INSTALLER, true);
            } else {
                /* For the retry iterations of download, modify the
                download status info in Status bar, and pass download to node */
                var attempt = (MAX_DOWNLOAD_ATTEMPTS - downloadAttemptsRemaining);
                if (attempt > 1) {
                    var info = attempt.toString() + "/5";
                    var status = {
                        target: "retry-download",
                        spans: [{
                            id: "attempt",
                            val: info
                        }]
                    };
                    UpdateStatus.modifyUpdateStatus(status);
                } else {
                    UpdateStatus.showUpdateStatus("retry-download");
                }
                postMessageToNode(MessageIds.DOWNLOAD_INSTALLER, false);
            }

            --downloadAttemptsRemaining;
        };

        if(!isAutoUpdateInitiated) {
            isAutoUpdateInitiated = true;
            updateJsonHandler.refresh()
                .done(function() {
                    setUpdateStateInJSON('downloadCompleted', false)
                        .done(downloadFn);
                });
        } else {
            setUpdateStateInJSON('downloadCompleted', false)
                .done(downloadFn);
        }
    }
100005
def download_file(self, f):
        
        #  os.chdir(self.directory)
        #  log.info('f=%s' % f)
        oldpwd = os.getcwd()
        try:
            os.chdir(self.directory)
            if is_local_filename(f.url):
                f.local_filename = abspath(f.url)
            else:
                if f.local_filename:
                    log.debug("Already downloaded: %s", f.local_filename)
                else:
                    f.local_filename = self.download_url(f.url, basename='%s/%s' % (f.fileGrp, f.ID))
        finally:
            os.chdir(oldpwd)

        #  print(f)
        return f
850586
def download
      response.headers['Content-Length'] = @attachment.file.size.to_s
      send_file(
        @attachment.file.path, {
          filename: @attachment.file_name,
          type: @attachment.file_mime_type
        }
      )
    end
413470
def download(self, filename, format='sdf', overwrite=False, resolvers=None, **kwargs):
        
        download(self.input, filename, format, overwrite, resolvers, **kwargs)
1253990
def maybe_download_and_extract(self):
        """"""
        if not os.path.exists(self.cifar10_dir):

            if not os.path.exists(self.data_dir):
                os.makedirs(self.data_dir)

            def _progress(count, block_size, total_size):
                status_msg = '\r>> Downloading {} {:>3}%   '
                sys.stdout.write(status_msg.format(self.cifar10_tarball, float(count * block_size) / total_size * 100.0))
                sys.stdout.flush()

            file_path, _ = urlretrieve(CIFAR10_URL, self.cifar10_tarball, _progress)

            stat_info = os.stat(file_path)
            print('\nSuccessfully downloaded', file_path, stat_info.st_size, 'bytes.\n')

            tarfile.open(file_path, 'r:gz').extractall(self.data_dir)
1127276
void executeAction( Action action ) throws PluginException {

		try {
			switch( action.actionType ) {
			case DELETE:
				this.logger.fine( "Deleting " + action.parameter + "..." );
				File f = new File( action.parameter );
				Utils.deleteFilesRecursively( f );
				break;

			case DOWNLOAD:
				this.logger.fine( "Downloading " + action.parameter + "..." );
				URI uri = UriUtils.urlToUri( action.parameter );
				File targetFile = new File( System.getProperty( "java.io.tmpdir" ), TMP_FILE );
				InputStream in = null;
				try {
					in = uri.toURL().openStream();
					Utils.copyStream( in, targetFile );

				} finally {
					Utils.closeQuietly( in );
				}

				break;

			case MOVE:
				List<String> parts = Utils.splitNicely( action.parameter, "->" );
				if( parts.size() != 2 ) {
					this.logger.warning( "Invalid syntax for 'move' action. " + action.parameter );
				} else {
					File source = new File( parts.get( 0 ));
					File target = new File( parts.get( 1 ));
					this.logger.fine( "Moving " + source + " to " + target + "..." );
					if( ! source.renameTo( target ))
						throw new IOException( source + " could not be moved to " + target );
				}

				break;

			case COPY:
				parts = Utils.splitNicely( action.parameter, "->" );
				if( parts.size() != 2 ) {
					this.logger.warning( "Invalid syntax for 'copy' action. " + action.parameter );
				} else {
					File source = new File( parts.get( 0 ));
					File target = new File( parts.get( 1 ));
					this.logger.fine( "Copying " + source + " to " + target + "..." );
					Utils.copyStream( source, target );
				}

				break;

			default:
				this.logger.fine( "Ignoring the action..." );
				break;
			}

		} catch( Exception e ) {
			throw new PluginException( e );
		}
	}
1220856
def _downloadfile(self, url, fname):
        '''  '''

        print("The file %s need to be download - Wait\n " %
              (fname.split('/')[-1]))
        urllib.urlretrieve(url, fname, self._report)
        print("\n The download of the file %s has succeded \n " %
              (fname.split('/')[-1]))
1272030
def click_download(self, event):
		
		args ['parallel'] = self.p.get()
		args ['file_type'] = self.optionmenu.get()
		args ['no_redirects'] = self.t.get()
		args ['query'] = self.entry_query.get()
		args ['min_file_size'] = int( self.entry_min.get())
		args ['max_file_size'] = int( self.entry_max.get())
		args ['limit'] = int( self.entry_limit.get())
		args ['website']= self.entry_website.get()
		args ['option']= self.engine.get()
		print(args)
		self.check_threat()
		download_content_gui( **args )
745139
public function downloadAction()
    {
        $fileManager = $this->container->get('thrace_media.filemanager');
        $filepath = $this->getRequest()->get('filepath');
        $filename = SlugFilter::filter($this->getRequest()->get('filename'));

        $content = $fileManager->getPermanentFileBlobByName($filepath);

        $response = new Response($content);
        $response->headers->set('Content-Length', mb_strlen($content));
        $response->headers->set('Content-Type', $this->getMimeType($content));
        $response->headers->set('Content-Disposition', 'attachment;filename=' . $filename);
        $response->expire();
        
        return $response;
    }
184844
def handle_download_click(self, *args):
        
        self.download_button.on_click(self.handle_download_click,remove=True)
        self.download_button.description = 'Downloading ...'
        self._string = self._fileobj.read()
        self.render_string()