Upload this content asset to the configured CDN
19640
public function uploadToContentService() {
		/** @var \File $file */
		$file = $this->owner;
		$writer = $this->writer();
		if (!$writer) {
			return;
		}
		$path = $file->getFullPath();
		if (strlen($path) && is_file($path) && file_exists($path)) {

			$mtime = @filemtime($path);
            $name = trim($file->getFilename(), '/');
		if (!$mtime) {
                    $mtime = '0';
                }

			//Insert the file modified time to make file unique-ish
			if ($lastPos = strrpos($name, '/')) {
				// Add in at as last folder name
				$name = substr($name, 0, $lastPos) . '/' . $mtime . substr($name, $lastPos);
			} else {
				//No folder found create one for the mtime
				$name = $mtime . '/' . $name;
			}

			$fileKeyLength = strlen($name);
			if ($fileKeyLength > CDNFile::MAX_FILE_PATH_LENGTH) {
				$lastPos = strrpos($name, '/');
				$ext = '';
				$filename = substr($name, $lastPos + 1);
				// Try and find a file extension
				if (strrpos($name, '.') !== false) {
					// Store and trim extension for later replacement
					$ext = substr($name, strrpos($name, '.'));
					$filename = substr($filename, 0, strrpos($filename, '.'));
				}
				// add 1 here so we can add in a ~ to indictate truncation
				$truncateLength = ($fileKeyLength + strlen($ext) + 1) - CDNFile::MAX_FILE_PATH_LENGTH;
				if (strlen($filename) <= $truncateLength) {
					// Folder length exceeds CDNFile::MAX_FILE_PATH_LENGTH. MD5 file to prevent file loss log error
					SS_Log::log("CDNFile: Total file length (folders + name) exceeds " . CDNFile::MAX_FILE_PATH_LENGTH . " characters and can't be "
							. "trimmed. File key has been MD5 encoded. File key: " . md5($name) . $ext . " Filename: "
							. "$name", SS_Log::ERR);
					$name = md5($name) . $ext;
				} else {
					// Recombine folder and file name while truncating the filename and appending a ~ then extension
					$name = substr($name, 0, $lastPos) . '/' . substr($filename, 0, (0 - $truncateLength)) . '~' . $ext;
				}
			}


			$writer->write(fopen($path, 'r'), $name);

			// writer should now have an id
			$file->CDNFile = $writer->getContentId();
            $file->FileSize = @filesize($path);

            // check whether it's an image, and handle its dimensions
            if ($file instanceof CdnImage) {
                $file->storeDimensions();
            }

			$file->write();

            // confirm the remote upload is there, and delete the local file
            // Oct 2016 - UNLESS the versioned files extension is on, we have to treat it slightly different
            $this->deleteLocalIfExistsOnContentService();
		}
	}
1268933
function resolveAssetLink(client, type) {
    var defaultPath = '/assets/' + client.name + '/' + client.id + '.' + type,
      pack = options.packedAssets,
      link = pack !== undefined ? (pack.cdn !== undefined ? pack.cdn[type] : void 0) : void 0;
    if (link) {
      if (typeof link === 'function') {
        var file = {
          id: client.id,
          name: client.name,
          extension: type,
          path: defaultPath
        };
        return link(file);
      } else if (typeof link === 'string') {
        return link;
      } else {
        throw new Error('CDN ' + type + ' param must be a Function or String');
      }
    } else {
      return defaultPath;
    }
  }
631202
def put_content(self, url, content):
        
        cache_path = self._url_to_path(url)

        # Ensure that cache directories exist
        try:
            dir = os.path.dirname(cache_path)
            os.makedirs(dir)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise Error('Failed to create cache directories for ' % cache_path)

        try:
            with open(cache_path, 'wb') as f:
                f.write(content)
        except IOError:
            raise Error('Failed to cache content as %s for %s' % (cache_path, url))
89822
def add_asset(self, filename, asset_type, display_name,
        encoding_rate=None, frame_width=None, frame_height=None,
        encode_to=None, encode_multiple=False,
        h264_preserve_as_rendition=False, h264_no_processing=False):
        
        m = hashlib.md5()
        fp = file(filename, 'rb')
        bits = fp.read(262144)  ## 256KB
        while bits:
            m.update(bits)
            bits = fp.read(262144)
        fp.close()

        hash_code = m.hexdigest()
        refid = "%s-%s" % (os.path.basename(filename), hash_code)

        asset = {
            'filename': filename,
            'type': asset_type,
            'size': os.path.getsize(filename),
            'refid': refid,
            'hash-code': hash_code}

        if encoding_rate:
            asset.update({'encoding-rate': encoding_rate})
        if frame_width:
            asset.update({'frame-width': frame_width})
        if frame_height:
            asset.update({'frame-height': frame_height})
        if display_name:
            asset.update({'display-name': display_name})
        if encode_to:
            asset.update({'encode-to': encode_to})
            asset.update({'encode-multiple': encode_multiple})
            if encode_multiple and h264_preserve_as_rendition:
                asset.update({
                    'h264-preserve-as-rendition': h264_preserve_as_rendition})
        else:
            if h264_no_processing:
                asset.update({'h264-no-processing': h264_no_processing})
        self.assets.append(asset)
376055
def _handle_assets(self, relpath, params):
    """"""
    if self._settings.assets_dir:
      abspath = os.path.normpath(os.path.join(self._settings.assets_dir, relpath))
      with open(abspath, 'rb') as infile:
        content = infile.read()
    else:
      content = pkgutil.get_data(__name__, os.path.join('assets', relpath))
    content_type = mimetypes.guess_type(relpath)[0] or 'text/plain'
    self._send_content(content, content_type)
1352885
def upload(local_path, remote_path, properties = {}, headers = {})
      artifact = Resource::Artifact.new(local_path: local_path)
      artifact.upload(key, remote_path, properties, headers)
    end
801460
def add_to_env(self, content):
        
        if not self.rewrite_config:
            raise DirectoryException("Error! Directory was not intialized w/ rewrite_config.")
        if not self.env_file:
            self.env_path, self.env_file = self.__get_env_handle(self.root_dir)
        self.env_file.write(content + '\n')
1140898
def upload_file(self, container, src_file_path, dst_name=None, put=True,
                    content_type=None):
        """"""
        if not os.path.exists(src_file_path):
            raise RuntimeError('file not found: ' + src_file_path)
        if not dst_name:
            dst_name = os.path.basename(src_file_path)
        if not content_type:
            content_type = "application/octet.stream"
        headers = dict(self._base_headers)
        if content_type:
            headers["content-length"] = content_type
        else:
            headers["content-length"] = "application/octet.stream"
        headers["content-length"] = str(os.path.getsize(src_file_path))
        headers['content-disposition'] = 'attachment; filename=' + dst_name
        if put:
            method = 'PUT'
            url = self.make_url(container, dst_name, None)
        else:
            method = 'POST'
            url = self.make_url(container, None, None)
        with open(src_file_path, 'rb') as up_file:
            try:
                rsp = requests.request(method, url, headers=headers,
                                       data=up_file, timeout=self._timeout)
            except requests.exceptions.ConnectionError as e:
                RestHttp._raise_conn_error(e)

        return self._handle_response(rsp)
1290226
public function AssetAction () {
		$ext = '';
		$path = $this->GetParam('path', 'a-zA-Z0-9_\-\/\.');
		$path = '/' . ltrim(str_replace('..', '', $path), '/');
		if (
			strpos($path, static::$staticPath) !== 0 &&
			strpos($path, static::$tmpPath) !== 0
		) {
			throw new \ErrorException("[".get_class($this)."] File path: '$path' is not allowed.", 500);
		}
		$path = $this->request->GetAppRoot() . $path;
		if (!file_exists($path)) {
			throw new \ErrorException("[".get_class($this)."] File not found: '$path'.", 404);
		}
		$lastDotPos = strrpos($path, '.');
		if ($lastDotPos !== FALSE) {
			$ext = substr($path, $lastDotPos + 1);
		}
		if (isset(self::$_assetsMimeTypes[$ext])) {
			header('Content-Type: ' . self::$_assetsMimeTypes[$ext]);
		}
		header_remove('X-Powered-By');
		header('Vary: Accept-Encoding');
		$assetMTime = @filemtime($path);
		if ($assetMTime) header('Last-Modified: ' . gmdate('D, d M Y H:i:s T', $assetMTime));
		readfile($path);
		exit;
	}
1338709
def upload_files(self, container, src_dst_map, content_type=None):
        """"""
        if not content_type:
            content_type = "application/octet.stream"
        url = self.make_url(container, None, None)
        headers = self._base_headers
        multi_files = []
        try:
            for src_path in src_dst_map:
                dst_name = src_dst_map[src_path]
                if not dst_name:
                    dst_name = os.path.basename(src_path)
                multi_files.append(
                    ('files', (dst_name, open(src_path, 'rb'), content_type)))

            rsp = requests.post(url, headers=headers, files=multi_files,
                                timeout=self._timeout)
        except requests.exceptions.ConnectionError as e:
            RestHttp._raise_conn_error(e)
        finally:
            for n, info in multi_files:
                dst, f, ctype = info
                f.close()

        return self._handle_response(rsp)
997735
def put_content(self, content):
        

        r = requests.request(self.method if self.method else 'PUT', self.url, data=content, **self.storage_args)
        if self.raise_for_status: r.raise_for_status()
375899
public function registerClientScript()
    {

        /* publish assets dir */
        $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets';
        $assetsUrl = $this->getAssetsUrl($path);

        /* @var $cs CClientScript */
        $cs = Yii::app()->getClientScript();

        $cs->registerCssFile($assetsUrl . '/css/jquery.fileupload-ui.css');

        // Upgrade widget factory
        // @todo remove when jquery.ui 1.9+ is fully integrated into stable Yii versions
        $cs->registerScriptFile($assetsUrl . '/js/vendor/jquery.ui.widget.js', CClientScript::POS_END);

        //The Templates plugin is included to render the upload/download listings
        $cs->registerScriptFile($assetsUrl . '/js/tmpl.min.js', CClientScript::POS_END);

        if ($this->previewImages || $this->imageProcessing) {
            $cs->registerScriptFile($assetsUrl . '/js/load-image.min.js', CClientScript::POS_END);
            $cs->registerScriptFile($assetsUrl . '/js/canvas-to-blob.min.js', CClientScript::POS_END);
            // gallery :)
            $this->getYiiWheels()->registerAssetCss("bootstrap-image-gallery.min.css");
            $this->getYiiWheels()->registerAssetJs("bootstrap-image-gallery.min.js", CClientScript::POS_END);
        }
        //The Iframe Transport is required for browsers without support for XHR file uploads
        $cs->registerScriptFile($assetsUrl . '/js/jquery.iframe-transport.js', CClientScript::POS_END);
        $cs->registerScriptFile($assetsUrl . '/js/jquery.fileupload.js', CClientScript::POS_END);

        // The File Upload image processing plugin
        if ($this->imageProcessing) {
            $cs->registerScriptFile($assetsUrl . '/js/jquery.fileupload-ip.js', CClientScript::POS_END);
        }
        // The File Upload file processing plugin
        if ($this->previewImages) {
            $cs->registerScriptFile($assetsUrl . '/js/jquery.fileupload-fp.js', CClientScript::POS_END);
        }
        // locale
        $cs->registerScriptFile($assetsUrl . '/js/jquery.fileupload-locale.js', CClientScript::POS_END);

        //The File Upload user interface plugin
        $cs->registerScriptFile($assetsUrl . '/js/jquery.fileupload-ui.js', CClientScript::POS_END);

        /* initialize plugin */
        $selector = '#' . TbArray::getValue('id', $this->htmlOptions, $this->getId());

        $this->getApi()->registerPlugin('fileupload', $selector, $this->options);
    }
177421
def upload_artifacts(self):
        """"""
        deploy_strategy = self.properties["deploy_strategy"]

        mirror = False
        if deploy_strategy == "mirror":
            mirror = True

        self._upload_artifacts_to_path(mirror=mirror)
        if deploy_strategy == "highlander":
            self._sync_to_uri(self.s3_latest_uri)
        elif deploy_strategy == "canary":
            self._sync_to_uri(self.s3_canary_uri)
        elif deploy_strategy == "alpha":
            self._sync_to_uri(self.s3_alpha_uri)
        elif deploy_strategy == "mirror":
            pass  # Nothing extra needed for mirror deployments
        else:
            raise NotImplementedError
1203966
def upload_package(context):
    """"""

    if not context.dry_run and build_distributions(context):
        upload_args = 'twine upload '
        upload_args += ' '.join(Path('dist').files())
        if context.pypi:
            upload_args += ' -r %s' % context.pypi

        upload_result = shell.dry_run(upload_args, context.dry_run)
        if not context.dry_run and not upload_result:
            raise Exception('Error uploading: %s' % upload_result)
        else:
            log.info(
                'Successfully uploaded %s:%s', context.module_name, context.new_version
            )
    else:
        log.info('Dry run, skipping package upload')
1045340
protected function setUp()
    {
        if (empty($this->asset)) {
            return;
        }

        $this->asset = $this->normalizePath($this->asset);
        $this->realPath = $this->locateResource();

        // The asset has not been located, so the full path is the asset itself
        if (null === $this->realPath) {
            $this->realPath = $this->asset;
        }
        $this->absolutePath = $this->retrieveBundleWebFolder();
    }
596898
def deploy(self):
        '''
            
        '''
        if not os.path.exists(self.path):
            makedirs(self.path)

        link(self.vault_path, self.real_path)
1373423
def create_at_path(self, asset_content, url_path, tags=''):
        

        return self._create_asset({
            'asset': b64encode(asset_content),
            'url-path': url_path,
            'tags': tags,
            'type': 'base64'
        })