Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uploadAsync not working #3

Closed
CCSS-Github opened this issue Dec 2, 2015 · 3 comments
Closed

uploadAsync not working #3

CCSS-Github opened this issue Dec 2, 2015 · 3 comments

Comments

@CCSS-Github
Copy link

Earlier we are using mulitpart form upload which is going to be deprecate. So we switch to UploadAsync method to upload image to S3 but its creating empty file with no content - image file only have source file path in it. Kindly guide

@CCSS-Github
Copy link
Author

Sample code:

            // checking valid local path
            if (!file_exists($local_file_url)) array("error"=>"invlid_path");

            // TODO: Bucket configuration as per environment
            $bucket = '';

            // image upload settings
            $concurrency = 5;
            $minPartSize = 1073741824; // 1024 MB

            // image upload aws
            // Yii::$app->get(S3_BUCKET)->multipartUpload(
                // "$desired_aws_url",
                // "$local_file_url",
                // $concurrency,
                // $minPartSize
            // );


            $promise = Yii::$app->get(S3_BUCKET)->uploadAsync(
                "$desired_aws_url",
                "$local_file_url",
                $concurrency,
                $minPartSize
            );



            // block until the result is ready
            $promise->wait();
            print_r($promise); exit;


        // Getting image absolute path from aws 
        $aws_url = Yii::$app->get(S3_BUCKET)->getUrl("$desired_aws_url");

        return $aws_url;

@frostealth
Copy link
Owner

Try

$promise = Yii::$app->get('bucket')->getClient()->uploadAsync(
    $bucket, 
    $filename, 
    $source, 
    $acl, 
    ['concurrency' => 5, 'part_size' => 1073741824]
);

If the problem persists:

$promise = Yii::$app->get('bucket')->uploadAsync(
    $filename,
    fopen($path_to_file, 'r+'),
    $concurrency,
    $minPartSize
);

The problem remains?

@cozumel424
Copy link

I just had the same issue, the second solution works ok, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants