Skip to content

storj-thirdparty/uplink-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

d2eab1b · Oct 4, 2022

History

24 Commits
Jul 19, 2022
Mar 5, 2021
Oct 4, 2022
Oct 4, 2022
Mar 5, 2021
Jul 20, 2022
Mar 5, 2021
Aug 30, 2022
Oct 4, 2022
Oct 4, 2022
May 25, 2021
Aug 30, 2022
Jul 20, 2022

Repository files navigation

Uplink PHP client

Client for Storj Decentralized Cloud Storage

Requirements

  • Storj API key or Access Grant. Obtain one from the dashboard (eu1, us1, ap1)
  • PHP >= 7.4
  • Any of:
    • Linux x86-64 with GLIBC >=2.28
    • Linux ARM64 with GLIBC >=2.28
    • Windows x86-64

Other platforms or older GLIBC versions are possible. You will need to compile Uplink-C for the platform and place the shared library in the "build" folder.

Installation

  1. Enable the FFI in php.ini:
extension=ffi
  1. (optional) To use it in web request also adjust this setting from "preload" to "true":
ffi.enable=true
  1. Add it as a requirement to your project's composer.json to install. Run:
composer config repositories.storj/uplink composer https://raw.githubusercontent.com/storj-thirdparty/uplink-php/main/
composer require storj/uplink

Performance

For better response times of your web app, you should not use an API key every request. Instead serialize your credentials to an Access Grant:

require 'vendor/autoload.php';
$access = \Storj\Uplink\Uplink::create()->requestAccessWithPassphrase(
    '12L9ZFwhzVpuEKMUNUqkaTLGzwY9G24tbiigLiXpmZWKwmcNDDs@eu1.storj.io:7777',
    'mybase58apikey',
    'mypassphrase'
);
$serialized = $access->serialize();
echo $serialized;

If you have already used uplink-cli you can read the Access Grant from ~/.local/share/storj/uplink/config.yaml or share it using $ uplink share

You can then use this in your web app:

$access = \Storj\Uplink\Uplink::create()->parseAccess($serialized);

Examples