Skip to content

Support storage API #7

@Leko

Description

@Leko

Changelog

2017/01/26
ストレージAPIを公開に伴い以下の情報を更新しました。
リクエストURL一覧にストレージの項目を追加しました。
機能別入出力パラメータ一覧にファイルアップロード・ファイルダウンロード・ファイル一覧取得を追加しました。
分類別フィールド一覧にストレージを追加しました。
メッセージ一覧に、ストレージAPIのメッセージを追加しました。

http://api.next-e.jp/index.php

Documents

Official SDK

	/**
	 * /api_v1_storage/downloadのレスポンスを元にファイルを解凍するメソッドです。
	 * @param  array	$response	/api_v1_storage/downloadのレスポンス
	 * @return string	解凍されたファイルデータの文字列。file_put_contents等でファイルに書き込むことでファイルを使用可能。
	 * @note   参考:http://php.net/manual/ja/function.file-put-contents.php
	 */
	public function decompressionFile($response) {
		if(isset($response["file_data"])) {
			return gzdecode(base64_decode($response['file_data']));
		}
	}

// -----

	protected function post($url, $params) {
		curl_setopt($this->_curl, CURLOPT_URL,				$url) ;
		curl_setopt($this->_curl, CURLOPT_POST,				true) ;
		
		if(!isset($params['file_data'])) {
			curl_setopt($this->_curl, CURLOPT_POSTFIELDS, $this->getUrlParams($params)) ;
		} else {
			// バージョンによってメソッドの利用が非推奨になっているため実行バージョンを判別して処理を分岐させる。
			if(version_compare(PHP_VERSION,
				self::PHP_VERSION_REQUIRED_CONSIDERATION,
				self::VERSION_COMPARE_OPERATOR)
			) {
				$params['file_data'] = new CURLFile($params['file_data']) ;
				curl_setopt($this->_curl, CURLOPT_SAFE_UPLOAD, true);
			} else {
				$params['file_data'] = '@'.$params['file_data'] ;
			}
			curl_setopt($this->_curl, CURLOPT_POSTFIELDS, $params) ;
		}
		$response = curl_exec($this->_curl) ;
		// ...

Workaround

Add new dependency form-data and file-type.
Then: https://github.com/bitinn/node-fetch#usage

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions