milesj / uploader

[Deprecated] A CakePHP plugin for file uploading and validating.
MIT License
193 stars 73 forks source link

Index problem in "Transport the files and save their remote path" #99

Closed leungpeng closed 11 years ago

leungpeng commented 11 years ago

I found that if the transforms array element contains key, there will be some warning during upload. The problem is that keySet in transforms may not equal to '$transportedFiles' keySet.

Problem( line 289 in AttachmentBehavior.php):

$dbColumn = $attachment['transforms'][($i - 1)]['dbColumn'];

Example: Original:

public $actsAs = array(
    'Uploader.Attachment' => array(
        'file' => array(
            ...
            'transforms' => array(
                'small'=>array(
                    'method' => 'resize',
                    'append' => '-small',
                    'width' => 160,
                    'height' => 120,
                    'aspect' => false,
                    'dbColumn'  => 'small',
                ),
                'med'=>array(
                    'method' => 'resize',
                    'append' => '-medium',
                    'width' => 640,
                    'height' => 480,
                    'aspect' => false,
                    'dbColumn'  => 'med',
                ),
            ),
            'transport' => array(
                'class' => 's3',
            ....
            )
        )
    ),
)

Finally,(work without warning)

public $actsAs = array(
    'Uploader.Attachment' => array(
        'file' => array(
            ...
            'transforms' => array(
                array(
                    'method' => 'resize',
                    'append' => '-small',
                    'width' => 160,
                    'height' => 120,
                    'aspect' => false,
                    'dbColumn'  => 'small',
                ),
                array(
                    'method' => 'resize',
                    'append' => '-medium',
                    'width' => 640,
                    'height' => 480,
                    'aspect' => false,
                    'dbColumn'  => 'med',
                ),
            ),
            'transport' => array(
                'class' => 's3',
            ....
            )
        )
    ),
)
milesj commented 11 years ago

Weird, I thought I fixed this before. Will fix ASAP.

milesj commented 11 years ago

Fixed in 4.0.4