Uname: Linux premium294.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
Software: LiteSpeed
PHP version: 8.1.32 [ PHP INFO ] PHP os: Linux
Server Ip: 104.21.64.1
Your Ip: 216.73.216.223
User: mjbynoyq (1574) | Group: mjbynoyq (1570)
Safe Mode: OFF
Disable Function:
NONE

name : S3Command.php
<?php
/**
 * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 * http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

namespace DuplicatorPro\Aws\S3\Command;

defined("ABSPATH") or die("");

use DuplicatorPro\Guzzle\Service\Command\OperationCommand;
use DuplicatorPro\Guzzle\Service\Resource\Model;
use DuplicatorPro\Guzzle\Common\Event;

/**
 * Adds functionality to Amazon S3 commands:
 * - Adds the PutObject URL to a response
 * - Allows creating a Pre-signed URL from any command
 */
class S3Command extends OperationCommand
{
    /**
     * Create a pre-signed URL for the operation
     *
     * @param int|string $expires The Unix timestamp to expire at or a string that can be evaluated by strtotime
     *
     * @return string
     */
    public function createPresignedUrl($expires)
    {
        return $this->client->createPresignedUrl($this->prepare(), $expires);
    }

    /**
     * {@inheritdoc}
     */
    protected function process()
    {
        $request = $this->getRequest();
        $response = $this->getResponse();

        // Dispatch an error if a 301 redirect occurred
        if ($response->getStatusCode() == 301) {
            $this->getClient()->getEventDispatcher()->dispatch('request.error', new Event(array(
                'request'  => $this->getRequest(),
                'response' => $response
            )));
        }

        parent::process();

        // Set the GetObject URL if using the PutObject operation
        if ($this->result instanceof Model && $this->getName() == 'PutObject') {
            $this->result->set('ObjectURL', $request->getUrl());
        }
    }
}
© 2025 XylotrechusZ