Generates the correct URL for serving a file

@param  string  $sObject        The object to serve
@param  string  $sBucket        The bucket to serve from
@param  boolean $bForceDownload Whether to force a download

@return string
420553
public function urlServe($sObject, $sBucket, $bForceDownload = false)
    {
        $sUrl       = $this->urlServeScheme($bForceDownload);
        $sFilename  = strtolower(substr($sObject, 0, strrpos($sObject, '.')));
        $sExtension = strtolower(substr($sObject, strrpos($sObject, '.')));

        //  Sub in the values
        $sUrl = str_replace('{{bucket}}', $sBucket, $sUrl);
        $sUrl = str_replace('{{filename}}', $sFilename, $sUrl);
        $sUrl = str_replace('{{extension}}', $sExtension, $sUrl);

        return $sUrl;
    }
1366284
@CheckForNull
    @Restricted(NoExternalUse.class)
    public String getMetadataUrlForDownloadable(String downloadable) {
        String siteUrl = getUrl();
        String updateSiteMetadataUrl = null;
        int baseUrlEnd = siteUrl.indexOf("update-center.json");
        if (baseUrlEnd != -1) {
            String siteBaseUrl = siteUrl.substring(0, baseUrlEnd);
            updateSiteMetadataUrl = siteBaseUrl + "updates/" + downloadable;
        } else {
            LOGGER.log(Level.WARNING, "Url {0} does not look like an update center:", siteUrl);
        }
        return updateSiteMetadataUrl;
    }
923955
public function getPublicUrl(string $resourcePath = '/', bool $isFullUrl = false, array $fullUrlInfo = [])
    {
        $url = $this->context . $resourcePath;
        if ($isFullUrl) {
            $this->formatUrlData($fullUrlInfo);
            $prefix = $fullUrlInfo['scheme'] . '://' . $fullUrlInfo['host'];
            if (($fullUrlInfo['scheme'] == 'http') && ($fullUrlInfo['port'] != 80)) {
                $prefix .= (':' . $fullUrlInfo['port']);
            } elseif (($fullUrlInfo['scheme'] == 'https') && ($fullUrlInfo['port'] != 443)) {
                $prefix .= (':' . $fullUrlInfo['port']);
            }
            $url = $prefix . $url;
        }
        return $url;
    }
621004
protected function _getSeoUrl($sObjectId, $iLang, $iShopId)
    {
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC);
        $aInfo = $oDb->getRow("select oxseourl, oxtype from oxseo where oxobjectid =  " . $oDb->quote($sObjectId) . " and oxlang =  " . $oDb->quote($iLang) . " and oxshopid = " . $oDb->quote($iShopId) . " order by oxparams limit 1");
        if ('oxarticle' == $aInfo['oxtype']) {
            $sMainCatId = $oDb->getOne("select oxcatnid from " . getViewName("oxobject2category") . " where oxobjectid = " . $oDb->quote($sObjectId) . " order by oxtime");
            if ($sMainCatId) {
                $sUrl = $oDb->getOne("select oxseourl from oxseo where oxobjectid =  " . $oDb->quote($sObjectId) . " and oxlang =  " . $oDb->quote($iLang) . " and oxshopid = " . $oDb->quote($iShopId) . " and oxparams = " . $oDb->quote($sMainCatId) . "  order by oxexpired");
                if ($sUrl) {
                    return $sUrl;
                }
            }
        }

        return $aInfo['oxseourl'];
    }
1193898
function downloadFileObject( $contentObject, $contentObjectAttribute )
    {
        $contentObjectAttributeID = $contentObjectAttribute->attribute( 'id' );
        $version = $contentObject->attribute( 'current_version' );
        $fileObject = eZBinaryFile::fetch( $contentObjectAttributeID, $version );
        if ( $fileObject )
            return $fileObject;
        $fileObject = eZMedia::fetch( $contentObjectAttributeID, $version );
        return $fileObject;
    }
735281
public function getQueryUrl($majorProtocolVersion = null,
        $minorProtocolVersion = null)
    {
        if (isset($this->_url)) {
            $url = $this->_url;
        } else {
            $url = Zend_Gdata_YouTube::VIDEO_URI;
        }
        if ($this->getCategory() !== null) {
            $url .= '/-/' . $this->getCategory();
        }
        $url = $url . $this->getQueryString($majorProtocolVersion,
            $minorProtocolVersion);
        return $url;
    }
1364634
public function objectLocalPath($sBucket, $sFilename)
    {
        $sPath = $this->getPath() . $sBucket . '/' . $sFilename;

        if (is_file($sPath)) {
            return $sPath;
        } else {
            $this->setError('Could not find a valid local path for object ' . $sBucket . '/' . $sFilename);
            return false;
        }
    }
240502
function uriToBlob(uri, done) {
  const xhr = new XMLHttpRequest();
  xhr.responseType = "blob";
  xhr.onload = () => {
    const blob = xhr.response;
    done(null, blob);
  };
  xhr.onerror = (err) => {
    done(err);
  };
  xhr.open("GET", uri);
  xhr.send();
}
193517
public function objectDestroy($sObject, $sBucket)
    {
        try {

            $sFilename  = strtolower(substr($sObject, 0, strrpos($sObject, '.')));
            $sExtension = strtolower(substr($sObject, strrpos($sObject, '.')));
            $this->sdk()->deleteObjects([
                'Bucket' => $this->getBucket(),
                'Delete' => [
                    'Objects' => [
                        ['Key' => $sBucket . '/' . $sFilename . $sExtension],
                        ['Key' => $sBucket . '/' . $sFilename . '-download' . $sExtension],
                    ],
                ],
            ]);
            return true;

        } catch (\Exception $e) {
            $this->setError('AWS-SDK EXCEPTION: [objectDestroy]: ' . $e->getMessage());
            return false;
        }
    }
138991
public function mediaDownload(ServerRequestInterface $request, Tree $tree): ResponseInterface
    {
        $xref    = $request->get('xref', '');
        $fact_id = $request->get('fact_id');
        $media   = Media::getInstance($xref, $tree);

        if ($media === null) {
            throw new MediaNotFoundException();
        }

        if (!$media->canShow()) {
            throw new AccessDeniedHttpException();
        }

        foreach ($media->mediaFiles() as $media_file) {
            if ($media_file->factId() === $fact_id) {
                if ($media_file->isExternal()) {
                    return redirect($media_file->filename());
                }

                if (!$media_file->isImage() && $media_file->fileExists()) {
                    $data = file_get_contents($media_file->getServerFilename());

                    return response($data, StatusCodeInterface::STATUS_OK, [
                        'Content-Type' => $media_file->mimeType(),
                        'Content-Disposition' => 'attachment; filename="' . addcslashes($media_file->filename(), '"') . '"',
                    ]);
                }
            }
        }

        throw new NotFoundHttpException();
    }
797902
public static function fetchBySourceURL( $url, $asObject = true )
    {
        return eZPersistentObject::fetchObject( self::definition(),
                                                null,
                                                array( "source_url" => $url ),
                                                $asObject );
    }
708214
private function _batchUrl($batchId, $subPath = '')
    {
        $ebid = rawurlencode($batchId);

        if (empty($ebid)) {
            throw new \InvalidArgumentException("Empty batch ID given");
        }

        return $this->_url('/batches/' . $ebid . $subPath);
    }
1293525
function downloadFile(cb) {
      if(task.file_path) {
        // Download the file
        var stream = fs.createWriteStream(path);

        // Store error if statusCode !== 200
        var err;
        stream.on("finish", function() {
          cb(err);
        });

        var urlToDownload = url.parse(task.file_path, false, true);

        // deny queries to ElasticSearch and other vulnerable services
        if(task.config.forbiddenPorts && task.config.forbiddenPorts.indexOf(urlToDownload.port) !== -1) {
          stream.end();
          return fs.unlink(path, function() {
            cb(new Error('Trying to access forbidden port: ' + urlToDownload.port));
          });
        }

        var req = request(urlToDownload.protocol + "//" + urlToDownload.host)
          .get(urlToDownload.path);

        // Warning, Black magic.
        // Streaming and checking for status code is no easy task...
        // Hours spent optimizing: 22
        req.end(function() {}).req.once('response', function(res) {
          if(res.statusCode !== 200) {
            if(res.statusCode === 410) {
              err = new Error('410 Gone');
              err.skip = true;
            }
            else {
              err = new Error('Error downloading file, got status ' + res.statusCode);
            }

            stream.end();
            this.abort();
          }
        });
        req.pipe(stream);
      }
      else {
        cb(null);
      }
    }
1118046
private String getBaseUrl(String pUrl, String pServletPath) {
        String sUrl;
        try {
            URL url = new URL(pUrl);
            String host = getIpIfPossible(url.getHost());
            sUrl = new URL(url.getProtocol(),host,url.getPort(),pServletPath).toExternalForm();
        } catch (MalformedURLException exp) {
            sUrl = plainReplacement(pUrl, pServletPath);
        }
        return sUrl;
    }
487887
function getObjectUrl (data) {
  let blob;

  if (typeof data === 'object' && data.constructor.name === 'Blob') {
    blob = data;
  } else if (typeof data === 'string') {
    blob = new Blob([getTextEncoder().encode(data).buffer], {
      type: 'application/octet-stream'
    });
  } else if (typeof data === 'object' && data.constructor && data.constructor.name === 'ArrayBuffer') {
    blob = new Blob([data], {
      type: 'application/octet-stream'
    });
  } else {
    throw new Error('in-browser-download: Data must either be a Blob, a string or an ArrayBuffer');
  }

  return URL.createObjectURL(blob);
}
418468
function getBlobLocalURL(blob) {
        if (!(blob instanceof Blob || blob instanceof File)) {
            throw new TypeError('Argument in BunnyFile.getBlobLocalURL() is not a Blob or File object');
        }
        return URL.createObjectURL(blob);
    }
1019281
public function inspect(Interfaces\JavaObject $javaObject): string
    {
        try {
            $inspect = $this->pjbProxyClient->inspect($javaObject);
        } catch (Pjb62BrokenConnectionException | Exception\InvalidUsageException $e) {
            PjbProxyClient::unregisterInstance();
            throw new BrokenConnectionException($e->getMessage(), $e->getCode(), $e);
        }

        return $inspect;
    }