GithubHelp home page GithubHelp logo

Comments (3)

yenfryherrerafeliz avatar yenfryherrerafeliz commented on June 10, 2024 1

Hi @Paril, thanks for reporting this. I was able to reproduce the issue by following your example. I am working on root causing it. I will provide updates as soon as possible.

Thanks!

from aws-sdk-php.

yenfryherrerafeliz avatar yenfryherrerafeliz commented on June 10, 2024 1

Hi @Paril, we are still working on getting this fixed; however, in the meantime, a workaround would be to provide a custom http handler in the client as following:

$s3 = new S3Client([
        'region' => getenv('TEST_REGION'),
        'version' => 'latest',
        'http_handler' => function (RequestInterface $request, $options) {
            return \Aws\default_http_handler()($request, $options);
        }
    ]);

I will provide more updates here, once we get this fixed.

Thanks!

from aws-sdk-php.

Paril avatar Paril commented on June 10, 2024

Here's a SSCEE of the problem. The only requirements is that:
a) all files and keynames referenced exist (except in the case of put dest files, obviously)
b) the PHP script does not have write access to the destination file for the get (ie, getObject must throw an exception)

	private function testBroken()
	{
		$bucketName	= '....'; // put in your bucket here
		$s3			= new Aws\S3\S3Client([
			'region' => 'us-east-1',
			'version' => 'latest'
		]);

		$get_key_name = 'files/sigs/test-put.png'; // must exist on S3
		$get_save_to = 'files/sigs/test-saveas.png'; // must either not exist, or not have permission to access

		try
		{
			// test get; this should throw
			$params = [
				'Bucket' => $bucketName,
				'Key' => $get_key_name
			];

			$params['SaveAs'] = $get_save_to;

			$file = $s3->getObject($params);
		}
		catch (Exception)
		{
			printf('got error, as expected\n');
		}

		try
		{
			// test put_many, this should not throw
			$put_files = [
				[ 'path' => 'files/sigs/test-0.png', 'key' => 'files/sigs/test-0.png' ], // source files must exist!
				[ 'path' => 'files/sigs/test-1.png', 'key' => 'files/sigs/test-1.png' ] ];
			$put_promises = [];

			foreach ($put_files as $file)
			{
				$put_promises[] = $s3->putObjectAsync([
					'Bucket' => $bucketName,
					'Key' => $file['key'],
					'ACL' => 'public-read',
					'SourceFile' => $file['path']
				]);
			}

			\GuzzleHttp\Promise\Utils::unwrap($put_promises);
			printf('put success\n');
		}
		catch (Exception)
		{
			printf('got error, unexpected!!\n');
		}
	}

Note that the following will happen:

  • got error, as expected will be logged. this is expected, obviously, as the file should not have write permissions. This is not the problem, and is expected!
  • got error, unexpected!! will be logged next. This is the bug. The exception, if you introspect it, will be the exception from the first get failure and not related to the put at all.

If you remove the getObject call entirely, the puts will succeed.

from aws-sdk-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.