├── undo_configure.sh ├── CHANGELOG.md ├── .idea ├── vcs.xml ├── .gitignore ├── phpunit.xml ├── modules.xml ├── inspectionProfiles │ └── Project_Default.xml ├── php-test-framework.xml ├── php.xml └── laravel-ipfs.iml ├── src ├── IPFSFacade.php ├── config │ └── ipfs.php ├── Exceptions │ └── IPFSException.php ├── IPFSServiceProvider.php ├── Traits │ └── MakesHttpRequests.php └── Clients │ └── IPFSClient.php ├── tests ├── TestCase.php └── Feature │ └── IPFSTest.php ├── LICENSE.md ├── phpunit.xml ├── composer.json ├── .gitignore └── README.md /undo_configure.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo "## revert to last commit" 3 | git reset head --hard 4 | git clean -f -d 5 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `laravel-ipfs` will be documented in this file. 4 | 5 | ## 1.0.0 - 202X-XX-XX 6 | 7 | - initial release 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Datasource local storage ignored files 5 | /dataSources/ 6 | /dataSources.local.xml 7 | # Editor-based HTTP Client requests 8 | /httpRequests/ 9 | -------------------------------------------------------------------------------- /.idea/phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/IPFSFacade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | -------------------------------------------------------------------------------- /.idea/php-test-framework.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/config/ipfs.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'base_url' => '127.0.0.1', 19 | 'port' => 5001, 20 | ], 21 | 22 | ]; 23 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | add(Utils::tryFopen('/Users/tomas/Downloads/algo_icon.png', 'r'), 'wow.png', ['pin' => true]); 16 | //$contents = $client->pin('QmNZdYefySKuzF37CWjR8vZ319gYToS61r3v3sRwApXgaY'); 17 | $contents = $client->cat('QmNZdYefySKuzF37CWjR8vZ319gYToS61r3v3sRwApXgaY'); 18 | dd($contents); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/Exceptions/IPFSException.php: -------------------------------------------------------------------------------- 1 | error_message = $error_message; 24 | } 25 | 26 | /** 27 | * Get the error message 28 | * 29 | * @return mixed 30 | */ 31 | public function getErrorMessage() 32 | { 33 | return $this->error_message; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/IPFSServiceProvider.php: -------------------------------------------------------------------------------- 1 | registerPublishables(); 13 | } 14 | 15 | public function register() 16 | { 17 | $this->mergeConfigFrom(__DIR__.'/config/ipfs.php', 'ipfs'); 18 | 19 | $this->app->singleton('ipfs', function ($app) { 20 | $baseUrl = config('ipfs.ipfs.base_url', '127.0.0.1'); 21 | $port = config('ipfs.ipfs.port', 5001); 22 | 23 | return new IPFSClient($baseUrl, $port); 24 | }); 25 | } 26 | 27 | protected function registerPublishables() 28 | { 29 | // php artisan vendor:publish --provider="Rootsoft\IPFS\IPFSServiceProvider" --tag="config" 30 | if ($this->app->runningInConsole()) { 31 | $this->publishes([ 32 | __DIR__.'/config/ipfs.php' => config_path('ipfs.php'), 33 | ], 'config'); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) rootsoft 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | src/ 19 | 20 | 21 | 22 | 23 | ./tests/Unit 24 | 25 | 26 | ./tests/Feature 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rootsoft/laravel-ipfs", 3 | "description": "Laravel package to communicate with IPFS", 4 | "keywords": [ 5 | "rootsoft", 6 | "laravel", 7 | "laravel-ipfs", 8 | "ipfs", 9 | "php" 10 | ], 11 | "homepage": "https://github.com/rootsoft/laravel-ipfs", 12 | "license": "MIT", 13 | "authors": [ 14 | { 15 | "name": "Tomas Verhelst", 16 | "email": "tomas.verhelst@kotapp.io", 17 | "role": "Developer" 18 | } 19 | ], 20 | "require": { 21 | "ext-json": "*", 22 | "php": "^7.4|^8.0", 23 | "guzzlehttp/guzzle": "^7.2", 24 | "league/flysystem": "^1.1.3" 25 | }, 26 | "require-dev": { 27 | "friendsofphp/php-cs-fixer": "^2.18", 28 | "orchestra/testbench": "^6.15", 29 | "phpunit/phpunit": "^9.3" 30 | }, 31 | "autoload": { 32 | "psr-4": { 33 | "Rootsoft\\IPFS\\": "src" 34 | } 35 | }, 36 | "autoload-dev": { 37 | "psr-4": { 38 | "Rootsoft\\IPFS\\Tests\\": "tests" 39 | } 40 | }, 41 | "extra": { 42 | "laravel": { 43 | "providers": [ 44 | "Rootsoft\\IPFS\\IPFSServiceProvider" 45 | ], 46 | "aliases": { 47 | "IPFS": "Rootsoft\\IPFS\\IPFSFacade" 48 | } 49 | } 50 | }, 51 | "scripts": { 52 | "test": "vendor/bin/phpunit", 53 | "test-coverage": "vendor/bin/phpunit --coverage-html coverage", 54 | "format": "vendor/bin/php-cs-fixer fix --allow-risky=yes" 55 | }, 56 | "config": { 57 | "sort-packages": true 58 | }, 59 | "minimum-stability": "dev", 60 | "prefer-stable": true 61 | } 62 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.toptal.com/developers/gitignore/api/laravel 2 | # Edit at https://www.toptal.com/developers/gitignore?templates=laravel 3 | 4 | ### Algorand ### 5 | /transactions/ 6 | .php_cs.cache 7 | 8 | ### Laravel ### 9 | /vendor/ 10 | node_modules/ 11 | npm-debug.log 12 | yarn-error.log 13 | 14 | # Laravel 4 specific 15 | bootstrap/compiled.php 16 | app/storage/ 17 | 18 | # Laravel 5 & Lumen specific 19 | public/storage 20 | public/hot 21 | 22 | # Laravel 5 & Lumen specific with changed public path 23 | public_html/storage 24 | public_html/hot 25 | 26 | storage/*.key 27 | .env 28 | Homestead.yaml 29 | Homestead.json 30 | /.vagrant 31 | .phpunit.result.cache 32 | 33 | # Laravel IDE helper 34 | *.meta.* 35 | _ide_* 36 | 37 | # End of https://www.toptal.com/developers/gitignore/api/laravel 38 | 39 | 40 | # Created by https://www.toptal.com/developers/gitignore/api/phpstorm 41 | # Edit at https://www.toptal.com/developers/gitignore?templates=phpstorm 42 | 43 | ### PhpStorm ### 44 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 45 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 46 | 47 | # User-specific stuff 48 | .idea/**/workspace.xml 49 | .idea/**/tasks.xml 50 | .idea/**/usage.statistics.xml 51 | .idea/**/dictionaries 52 | .idea/**/shelf 53 | 54 | # Generated files 55 | .idea/**/contentModel.xml 56 | 57 | # Sensitive or high-churn files 58 | .idea/**/dataSources/ 59 | .idea/**/dataSources.ids 60 | .idea/**/dataSources.local.xml 61 | .idea/**/sqlDataSources.xml 62 | .idea/**/dynamic.xml 63 | .idea/**/uiDesigner.xml 64 | .idea/**/dbnavigator.xml 65 | 66 | # Gradle 67 | .idea/**/gradle.xml 68 | .idea/**/libraries 69 | 70 | # Gradle and Maven with auto-import 71 | # When using Gradle or Maven with auto-import, you should exclude module files, 72 | # since they will be recreated, and may cause churn. Uncomment if using 73 | # auto-import. 74 | # .idea/artifacts 75 | # .idea/compiler.xml 76 | # .idea/jarRepositories.xml 77 | # .idea/modules.xml 78 | # .idea/*.iml 79 | # .idea/modules 80 | # *.iml 81 | # *.ipr 82 | 83 | # CMake 84 | cmake-build-*/ 85 | 86 | # Mongo Explorer plugin 87 | .idea/**/mongoSettings.xml 88 | 89 | # File-based project format 90 | *.iws 91 | 92 | # IntelliJ 93 | out/ 94 | 95 | # mpeltonen/sbt-idea plugin 96 | .idea_modules/ 97 | 98 | # JIRA plugin 99 | atlassian-ide-plugin.xml 100 | 101 | # Cursive Clojure plugin 102 | .idea/replstate.xml 103 | 104 | # Crashlytics plugin (for Android Studio and IntelliJ) 105 | com_crashlytics_export_strings.xml 106 | crashlytics.properties 107 | crashlytics-build.properties 108 | fabric.properties 109 | 110 | # Editor-based Rest Client 111 | .idea/httpRequests 112 | 113 | # Android studio 3.1+ serialized cache file 114 | .idea/caches/build_file_checksums.ser 115 | 116 | ### PhpStorm Patch ### 117 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 118 | 119 | # *.iml 120 | # modules.xml 121 | # .idea/misc.xml 122 | # *.ipr 123 | 124 | # Sonarlint plugin 125 | # https://plugins.jetbrains.com/plugin/7973-sonarlint 126 | .idea/**/sonarlint/ 127 | 128 | # SonarQube Plugin 129 | # https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin 130 | .idea/**/sonarIssues.xml 131 | 132 | # Markdown Navigator plugin 133 | # https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced 134 | .idea/**/markdown-navigator.xml 135 | .idea/**/markdown-navigator-enh.xml 136 | .idea/**/markdown-navigator/ 137 | 138 | # Cache file creation bug 139 | # See https://youtrack.jetbrains.com/issue/JBR-2257 140 | .idea/$CACHE_FILE$ 141 | 142 | # CodeStream plugin 143 | # https://plugins.jetbrains.com/plugin/12206-codestream 144 | .idea/codestream.xml 145 | 146 | # End of https://www.toptal.com/developers/gitignore/api/phpstorm -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | # laravel-ipfs 6 | [![Packagist][packagist-shield]][packagist-url] 7 | [![Downloads][downloads-shield]][downloads-url] 8 | [![Issues][issues-shield]][issues-url] 9 | [![MIT License][license-shield]][license-url] 10 | 11 | The InterPlanetary File System is a peer-to-peer hypermedia protocol designed to make the web faster, safer, and more open. 12 | IPFS uses content-addressing to uniquely identify each file in a global namespace connecting all computing devices. 13 | 14 | It is an ideal solution for a decentralized storage for blockchain-based content and is optimized for the [Algorand blockchain](https://www.algorand.com/) . 15 | 16 | ## Introduction 17 | laravel-ipfs is a simple wrapper around the IPFS HTTP API with an elegant approach to connect your application to the IPFS network so you can easily host and fetch content with just a few lines of code. 18 | 19 | Once installed, you can simply connect your application to the network and add content: 20 | 21 | ```php 22 | $ipfs->add(Utils::tryFopen('ipfs.png', 'r'), 'ipfs.png', ['pin' => true]); 23 | ``` 24 | 25 | or show IPFS object data: 26 | 27 | ```php 28 | $contents = $ipfs->cat('QmNZdYefySKuzF37CWjR8vZ319gYToS61r3v3sRwApXgaY'); 29 | ``` 30 | 31 | ## Getting started 32 | 33 | ### Installation 34 | > **Note**: laravel-ipfs requires PHP 7.4+ 35 | 36 | You can install the package via composer: 37 | 38 | ```bash 39 | composer require rootsoft/laravel-ipfs 40 | ``` 41 | 42 | ## Usage 43 | Create an new ```IPFSClient``` and pass the IP address and port of your local (or [pinned](https://pinata.cloud/)) network. 44 | 45 | ```php 46 | $ipfs = new IPFSClient('127.0.0.1', 5001); 47 | ``` 48 | 49 | **That's it!** We can now easily add new content on a decentralized network! 50 | 51 | ### Laravel :heart: 52 | We've added special support to make the life of a Laravel developer even more easy! 53 | 54 | Publish the ```ipfs.php``` config file using: 55 | ``` 56 | php artisan vendor:publish --provider="Rootsoft\IPFS\IPFSServiceProvider" --tag="config" 57 | ``` 58 | 59 | Open the ```config/ipfs.php``` file in your project and insert your credentials 60 | ```php 61 | return [ 62 | 'ipfs' => [ 63 | 'base_url' => '127.0.0.1', 64 | 'port' => 5001, 65 | ], 66 | ]; 67 | ``` 68 | 69 | Now you can use the ```IPFS``` Facade! 70 | 71 | ```php 72 | $fileHash = IPFS::add($collectible->get(), $fileName, ['only-hash' => true])['Hash']; 73 | ``` 74 | 75 | ## Methods 76 | 77 | 78 | ## Changelog 79 | 80 | Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. 81 | 82 | ## Contributing & Pull Requests 83 | Feel free to send pull requests. 84 | 85 | Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details. 86 | 87 | ## Credits 88 | 89 | - [Tomas Verhelst](https://github.com/rootsoft) 90 | - [All Contributors](../../contributors) 91 | 92 | ## License 93 | 94 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 95 | 96 | 97 | 98 | 99 | [packagist-shield]: https://img.shields.io/packagist/v/rootsoft/laravel-ipfs.svg?style=for-the-badge 100 | [packagist-url]: https://packagist.org/packages/rootsoft/laravel-ipfs 101 | [downloads-shield]: https://img.shields.io/packagist/dt/rootsoft/laravel-ipfs.svg?style=for-the-badge 102 | [downloads-url]: https://packagist.org/packages/rootsoft/laravel-ipfs 103 | [issues-shield]: https://img.shields.io/github/issues/rootsoft/laravel-ipfs.svg?style=for-the-badge 104 | [issues-url]: https://github.com/rootsoft/laravel-ipfs/issues 105 | [license-shield]: https://img.shields.io/github/license/rootsoft/laravel-ipfs.svg?style=for-the-badge 106 | [license-url]: https://github.com/rootsoft/laravel-ipfs/blob/master/LICENSE.md -------------------------------------------------------------------------------- /src/Traits/MakesHttpRequests.php: -------------------------------------------------------------------------------- 1 | request('GET', $uri, $params); 23 | } 24 | 25 | /** 26 | * Make a POST request and return the response. 27 | * 28 | * @param string $uri 29 | * @param array $queryParams 30 | * @param array $payload 31 | * @param array $headers 32 | * @return mixed 33 | * @throws IPFSException 34 | */ 35 | protected function post(string $uri, array $queryParams = [], array $payload = [], array $headers = []) 36 | { 37 | return $this->request('POST', $uri, $queryParams, $payload, $headers); 38 | } 39 | 40 | /** 41 | * Make a PUT request and return the response. 42 | * 43 | * @param string $uri 44 | * @param array $payload 45 | * @return mixed 46 | * @throws IPFSException 47 | */ 48 | protected function put(string $uri, array $payload = []) 49 | { 50 | return $this->request('PUT', $uri, $payload); 51 | } 52 | 53 | /** 54 | * Make a DELETE request and return the response. 55 | * 56 | * @param string $uri 57 | * @param array $payload 58 | * @return mixed 59 | * @throws IPFSException 60 | */ 61 | protected function delete(string $uri, array $payload = []) 62 | { 63 | return $this->request('DELETE', $uri, $payload); 64 | } 65 | 66 | /** 67 | * Make request and return the response. 68 | * 69 | * @param string $verb 70 | * @param string $uri 71 | * @param array $queryParams 72 | * @param array $payload 73 | * @param array $headers 74 | * @return mixed 75 | * @throws IPFSException 76 | */ 77 | protected function request(string $verb, string $uri, array $queryParams = [], array $payload = [], array $headers = []) 78 | { 79 | // Strip leading slashes - RFC 3986 80 | $uri = ltrim($uri, DIRECTORY_SEPARATOR); 81 | 82 | // Build the options 83 | $options = $this->buildOptions($verb, $queryParams, $payload, $headers); 84 | 85 | // Make the request 86 | try { 87 | $response = $this->client->request( 88 | $verb, 89 | $uri, 90 | $options, 91 | ); 92 | } catch (GuzzleException $e) { 93 | throw new IPFSException($e->getMessage()); 94 | } 95 | 96 | if ($response->getStatusCode() != 200) { 97 | $this->handleRequestError($response); 98 | } 99 | 100 | $responseBody = (string) $response->getBody()->getContents(); 101 | 102 | return json_decode($responseBody, true) ?: $responseBody; 103 | } 104 | 105 | /** 106 | * Handle the request error. 107 | * 108 | * @param ResponseInterface $response 109 | * @return void 110 | * @throws IPFSException 111 | */ 112 | protected function handleRequestError(ResponseInterface $response) 113 | { 114 | $errorMessage = $response->getBody()->getContents(); 115 | if ($response->getStatusCode() == 401 || $response->getStatusCode() == 403) { 116 | throw new IPFSException((string) $response->getBody()); 117 | } 118 | 119 | if ($response->getStatusCode() == 404) { 120 | throw new IPFSException((string) $response->getBody()); 121 | } 122 | 123 | throw new IPFSException((string) $response->getBody()); 124 | } 125 | 126 | /** 127 | * @param string $method 128 | * 129 | * @param array $queryParams 130 | * @param array $payload 131 | * @param array $headers 132 | * @return array 133 | */ 134 | private function buildOptions($method = 'get', array $queryParams = [], array $payload = [], array $headers = []) 135 | { 136 | $options = [ 137 | 'query' => [], 138 | ]; 139 | 140 | // Add the query params 141 | $options['query'] = array_merge($options['query'], $queryParams); 142 | 143 | if ($method == 'POST') { 144 | if (! array_key_exists('body', $payload)) { 145 | // Body is given 146 | $options = array_merge($payload, $options); 147 | } else { 148 | // Body is given 149 | $options = array_merge($payload, $options); 150 | } 151 | } 152 | 153 | $options['http_errors'] = false; 154 | 155 | if (! empty($headers)) { 156 | $options['headers'] = $headers; 157 | } 158 | 159 | return $options; 160 | } 161 | 162 | } 163 | -------------------------------------------------------------------------------- /src/Clients/IPFSClient.php: -------------------------------------------------------------------------------- 1 | baseUrl = $baseUrl; 54 | $this->port = $port; 55 | $this->timeout = $timeout; 56 | 57 | $this->client = new Client([ 58 | 'base_uri' =>self::format_url("$this->baseUrl:$this->port/api/$this->version/"), 59 | 'timeout' => $this->timeout, 60 | 'http_errors' => false, 61 | 'headers' => [ 62 | 'Accept' => 'application/json', 63 | 'Content-Type' => 'application/json', 64 | ], 65 | ]); 66 | } 67 | 68 | private static function format_url(string $baseUrl) 69 | { 70 | return rtrim($baseUrl, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; 71 | } 72 | 73 | /** 74 | * Show IPFS node id info. 75 | * 76 | * More information: https://docs.ipfs.io/reference/http/api/#api-v0-add 77 | * @param array $queryParams 78 | * @return array 79 | * @throws \Rootsoft\IPFS\Exceptions\IPFSException 80 | */ 81 | public function id(array $queryParams = []) 82 | { 83 | return $this->post('id', $queryParams); 84 | } 85 | 86 | /** 87 | * Show IPFS object data. 88 | * 89 | * More information: https://docs.ipfs.io/reference/http/api/#api-v0-add 90 | * @param string $hash The path to the IPFS object(s) to be outputted. 91 | * @param array $queryParams 92 | * @return mixed 93 | * @throws \Rootsoft\IPFS\Exceptions\IPFSException 94 | */ 95 | public function cat(string $hash, array $queryParams = []) 96 | { 97 | return $this->post("cat/$hash", $queryParams); 98 | } 99 | 100 | /** 101 | * Add a file or directory to IPFS. 102 | * 103 | * More information: https://docs.ipfs.io/reference/http/api/#api-v0-add 104 | * @param string|mixed $data a string to send the contents of the file as a string or an fopen resource to stream the contents from a PHP stream. 105 | * @param string $fileName The name of the file 106 | * @param array $queryParams 107 | * @return mixed 108 | * @throws \Rootsoft\IPFS\Exceptions\IPFSException 109 | */ 110 | public function add($data, $fileName = '', array $queryParams = []) 111 | { 112 | $multipart = [ 113 | 'multipart' => [ 114 | [ 115 | 'name' => "data", 116 | 'contents' => $data, 117 | 'filename' => $fileName, 118 | ], 119 | ], 120 | ]; 121 | 122 | return $this->post("add", $queryParams, $multipart); 123 | } 124 | 125 | /** 126 | * List directory contents for UnixFS objects. 127 | * 128 | * https://docs.ipfs.io/reference/http/api/#api-v0-ls 129 | * @param string $hash The path to the IPFS object(s) to list links from. 130 | * @param array $queryParams 131 | * @return mixed 132 | * @throws \Rootsoft\IPFS\Exceptions\IPFSException 133 | */ 134 | public function ls(string $hash, array $queryParams = []) 135 | { 136 | return $this->post("ls/$hash", $queryParams); 137 | } 138 | 139 | /** 140 | * Get the size of the UnixFS object. 141 | * 142 | * https://docs.ipfs.io/reference/http/api/#api-v0-object-stat 143 | * @param string $hash The path to the IPFS object to get the size from. 144 | * @param array $queryParams 145 | * @return mixed 146 | * @throws \Rootsoft\IPFS\Exceptions\IPFSException 147 | */ 148 | public function size(string $hash, array $queryParams = []) 149 | { 150 | return $this->post("object/stat/$hash", $queryParams)['CumulativeSize']; 151 | } 152 | 153 | /** 154 | * Get stats for the DAG node named by . 155 | * 156 | * https://docs.ipfs.io/reference/http/api/#api-v0-object-stat 157 | * @param string $hash The path to the IPFS object to get the stats from. 158 | * @param array $queryParams 159 | * @return mixed 160 | * @throws \Rootsoft\IPFS\Exceptions\IPFSException 161 | */ 162 | public function stats(string $hash, array $queryParams = []) 163 | { 164 | return $this->post("object/stat/$hash", $queryParams); 165 | } 166 | 167 | /** 168 | * Pin objects to local storage. 169 | * 170 | * https://docs.ipfs.io/reference/http/api/#api-v0-pin-add 171 | * @param string $hash The path to the IPFS object that you want to pin. 172 | * @param array $queryParams 173 | * @return mixed 174 | * @throws \Rootsoft\IPFS\Exceptions\IPFSException 175 | */ 176 | public function pin(string $hash, array $queryParams = []) 177 | { 178 | return $this->post("pin/add/$hash", $queryParams); 179 | } 180 | 181 | /** 182 | * Remove pinned objects from local storage. 183 | * 184 | * https://docs.ipfs.io/reference/http/api/#api-v0-pin-rm 185 | * @param string $hash The path to the IPFS object that you want to unpin. 186 | * @param array $queryParams 187 | * @return mixed 188 | * @throws \Rootsoft\IPFS\Exceptions\IPFSException 189 | */ 190 | public function unpin(string $hash, array $queryParams = []) 191 | { 192 | return $this->post("pin/rm/$hash", $queryParams); 193 | } 194 | } 195 | -------------------------------------------------------------------------------- /.idea/php.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /.idea/laravel-ipfs.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | --------------------------------------------------------------------------------