posts media file
@param  string $path      Local path of media file
@param  string $mime_type file mime-type
341910
public function postRaw($path, $mime_type)
    {
        $this->setTokenValue($this->getEntityIdName(), $this->getId());
        $bin = file_get_contents($path);
        $b64 = 'data:'.$mime_type.';base64,'.base64_encode($bin);
        $uri = $this->getURI('/raw');
        $x   = $this->getSDK()->post($uri, $b64, array('Content-Type' => 'application/x-base64'));
    }
264099
private static function createFromFileByMime($path)
    {
        $mime = File::getMimeType($path);
        switch ($mime) {
            case 'image/jpeg':
                $img = imagecreatefromjpeg($path);
                break;
            case 'image/gif':
                $img = imagecreatefromgif($path);
                break;
            case 'image/png':
                $img = imagecreatefrompng($path);
                break;
            default:
                throw new \Exception('can`t create thumbnail: unknown image type');
        }

        if ( ! $img) {
            throw new \Exception('can`t create thumbnail: can`t create image handle from file ' . $path);
        }

        return $img;
    }
876245
private static void loadMIMETypesFile(String path) {
        try {
            File f = new File(path);

            logger.debug("Attempting to load MIME types file \"" + path + "\"");
            if (!(f.exists() && f.isFile()))
                logger.debug("Regular file \"" + path + "\" does not exist.");

            else {
                LineNumberReader r = new LineNumberReader(new FileReader(f));
                String line;

                while ((line = r.readLine()) != null) {
                    line = line.trim();

                    if ((line.length() == 0) || (line.startsWith("#")))
                        continue;

                    String[] fields = line.split(" ");

                    // Skip lines without at least two tokens.

                    if (fields.length < 2) continue;

                    // Special case: Scan the extensions, and make sure we
                    // have at least one valid extension. Some .mime.types
                    // files have entries like this:
                    //
                    // mime/type  desc="xxx" exts="jnlp"
                    //
                    // We don't handle those.

                    List<String> extensions = new ArrayList<String>();

                    for (int i = 1; i < fields.length; i++) {
                        if (fields[i].indexOf('=') != -1) continue;
                        if (fields[i].indexOf('"') != -1) continue;

                        // Treat as valid. Remove any leading "."

                        if (fields[i].startsWith(".")) {
                            if (fields[i].length() == 1) continue;

                            fields[i] = fields[i].substring(1);
                        }

                        extensions.add(fields[i]);
                    }

                    if (extensions.size() == 0) continue;

                    // If the MIME type doesn't have a "/", skip it

                    String mimeType = fields[0];
                    String extension;

                    if (mimeType.indexOf('/') == -1) continue;

                    // The first field is the preferred extension. Keep any
                    // existing mapping for the MIME type.

                    if (mimeTypeToExtensionMap.get(mimeType) == null) {
                        extension = extensions.get(0);
                        logger.debug("File \"" + path + "\": " + mimeType
                                + " -> \"" + extension + "\"");

                        mimeTypeToExtensionMap.put(mimeType, extension);
                    }
                }

                r.close();
            }
        } catch (IOException ex) {
            logger.debug("Error reading \"" + path + "\"", ex);
        }
    }
936142
public function updatePsrStream($path, StreamInterface $stream, $mimeType = null)
    {
        return $this->getFile($path)->update($stream, $mimeType);
    }
1263093
public static void post(String path, String acceptType, Route route) {
        getInstance().post(path, acceptType, route);
    }
269014
public function serveFile($filePath, $mimeType) {
		// if the file exists at the specified path
		if (\file_exists($filePath) && \is_file($filePath)) {
			\header('Content-Type: ' . $mimeType, true);
			\header('Accept-Ranges: none', true);
			\header('Connection: close', true);

			// pipe the actual file contents through PHP
			\readfile($filePath);
		}
		// if the file could not be found
		else {
			throw new \RuntimeException('File `' . $filePath . '` not found');
		}
	}
661793
public function add_additional_mime_type_support($post_mime_types)
    {
        $additional_mime_types = [
            'application/msword' => [
                \__('Word Docs', 'snap'),
                \__('Manage Word Docs', 'snap'),
                \_n_noop('Word Doc <span class="count">(%s)</span>', 'Word Docs <span class="count">(%s)</span>'),
            ],
            'application/vnd.ms-excel' => [
                \__('Excel Docs', 'snap'),
                \__('Manage Excel Docs', 'snap'),
                \_n_noop('Excel Doc <span class="count">(%s)</span>', 'Excel Docs <span class="count">(%s)</span>'),
            ],
            'application/pdf' => [
                \__('PDFs', 'snap'),
                \__('Manage PDFs', 'snap'),
                \_n_noop('PDF <span class="count">(%s)</span>', 'PDFs <span class="count">(%s)</span>'),
            ],
            'application/zip' => [
                \__('ZIPs', 'snap'),
                \__('Manage ZIPs', 'snap'),
                \_n_noop('ZIP <span class="count">(%s)</span>', 'ZIPs <span class="count">(%s)</span>'),
            ],
            'text/csv' => [
                \__('CSVs', 'snap'),
                \__('Manage CSVs', 'snap'),
                \_n_noop('CSV <span class="count">(%s)</span>', 'CSVs <span class="count">(%s)</span>'),
            ],
        ];

        return \array_merge($post_mime_types, $additional_mime_types);
    }
336366
public function post($path, $parameters)
    {
        $request = $this->getRequest(static::HTTP_POST, $path, $parameters);

        return $this->sendRequest($request);
    }
453176
public static function file($path, $type = null)
    {
        $response = new self(
            Status::OK,
            new PhpStream($path, 'rb')
        );
        if (isset($type)) {
            $response->setHeader('Content-Type', $type);
        }
        return $response;
    }
764838
def UploadType(cls, file_path):
        
        if not os.path.isabs(file_path):
            return False
        
        if os.path.isfile(file_path):
            cls.SendKeys(file_path)
        else:            
            return False
4196
protected function gdImageCreate($path,$mime){
		switch($mime){
			case 'image/jpeg':
			return imagecreatefromjpeg($path);

			case 'image/png':
			return imagecreatefrompng($path);

			case 'image/gif':
			return imagecreatefromgif($path);

			case 'image/xbm':
			return imagecreatefromxbm($path);
		}
		return false;
	}
1138358
public function asFileContents($file_loc, $mime)
    {
        $stream = StreamFactory::file($file_loc);
        return new Response($stream, self::OK, ['Content-Type' => $mime]);
    }
785912
def mime_type(self, path):
        """"""
        name, ext = os.path.splitext(path)
        return MIME_TYPES[ext]
971531
public function file($field, $path, $type, $name)
    {
        $name = basename($name);
        if (class_exists('CURLFile')) {
            $this->set('CURLOPT_SAFE_UPLOAD', true);
            $file = curl_file_create($path, $type, $name);
        } else {
            $file = "@{$path};type={$type};filename={$name}";
        }
        return $this->post($field, $file);
    }
1178958
public function post($path, $params)
    {
        $idempotencyKey = uniqid("", true);
        $paramsWithHeaders = array("headers" => array("Idempotency-Key" => $idempotencyKey));
        $params = array_replace_recursive($paramsWithHeaders, $params);

        $response = $this->http_client->request('POST', $path, $params);

        $this->handleErrors($response);
        return $response;
    }
873865
public function post($path, $parameters = null, $version = null, $etag = null)
        {
            return $this->api('POST', $path, $parameters, $version, $etag);
        }
1039481
private function uploadMediaNotChunked($path, $parameters)
    {
        $file = file_get_contents($parameters['media']);
        $base = base64_encode($file);
        $parameters['media'] = $base;
        return $this->http('POST', self::UPLOAD_HOST, $path, $parameters);
    }