'latest', 'region' => $awsRegion, ]); // Retrieve data about the file to be uploaded from the request body. $body = json_decode(file_get_contents('php://input')); $filename = $body->filename; $contentType = $body->contentType; // Prepare a PutObject command. $command = $s3->getCommand('putObject', [ 'Bucket' => $bucket, 'Key' => "{$directory}/{$filename}", 'ContentType' => $contentType, 'Body' => '', ]); $request = $s3->createPresignedRequest($command, '+5 minutes'); header('content-type: application/json'); echo json_encode([ 'method' => $request->getMethod(), 'url' => (string) $request->getUri(), 'fields' => [], ]);