GrahamCampbell/Laravel-Flysystem

DigitalOcean Spaces

timgavin opened this issue ยท 5 comments

Any plans for supporting DigitalOcean's Object Storage?

If there's a flysystem connector implemented, then sure. :)

It looks like this will be problematic because digital ocean spaces requires V2 of pre-signed URL signature and the AWS client and all the flystem stuff only supports V4 and the two are not compatible. Trying to use older versions of flystem isn't possible because it requires an outdated version of the aws sdk php. You could require the outdated versions in composer, however this would stop the other drivers from working (you couldn't have both digital ocean spaces and aws s3 for instance).

I've spent a few hours on this with no luck unfortunately, but that info might help anyone else looking to use digital ocean spaces.

I'm facing the same issue. I tried to install league/flysystem-aws-s3-v2 but I also wasnt able to get it working correctly.

Here is some example code for anyone who wants to use V2 signing:

    public function downloadUrl($minutes = 10)
    {
        $expires = Carbon::now()->addMinutes($minutes);
        $config = config('filesystems.disks')[config('filesystems.default')];
        $uri = $this->filename;

        $signature = $this->generateSignature($config, $expires, $uri);

        return "{$config['endpoint']}/{$config['bucket']}/{$uri}?AWSAccessKeyId={$config['key']}&Expires={$expires->timestamp}&Signature={$signature}";
    }


    /**
     * Signs a request.
     *
     * @param $config
     * @param $expires
     * @param $uri
     * @return string
     */
    protected function generateSignature($config, $expires, $uri)
    {
        $request = "GET\n\n\n{$expires->timestamp}\n/{$config['bucket']}/{$uri}";

        return urlencode(base64_encode(hash_hmac('sha1', $request, $config['secret'], true)));
    }

FYI for anyone interested, DO supports v4 now and thus the normal S3 signing works ๐Ÿ˜„