Skip to content

storj-thirdparty/uplink-php

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(
    '[email protected]: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