Plugin Directory

Changeset 737670


Ignore:
Timestamp:
07/08/2013 09:37:42 AM (13 years ago)
Author:
atvdev
Message:

update to 1.9.4
new bucket location "ap-southeast-2" in form
wp_upload_dir seperated to local and s3 paths
added commented out file upload integration

Location:
amazon-s3-uploads/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • amazon-s3-uploads/trunk/asssu.php

    r730022 r737670  
    66Author URI: https://profiles.google.com/117859515361389646005
    77Description: Moves your uploads to Amazon S3 via cron jobs.
    8 Version: 1.9.3
     8Version: 1.9.4
    99*/
    1010
  • amazon-s3-uploads/trunk/plugin/asssu/__init.php

    r730022 r737670  
    4343   
    4444    public static
    45         $version = '1.9.3';
     45        $version = '1.9.4';
    4646       
    4747    public
     
    6363        $this->site_url = \get_option('siteUrl');
    6464        $this->site_url = trim(substr($this->site_url, strpos($this->site_url, '://') + 3), '/');
    65         $this->wp_upload_dir = \wp_upload_dir();
     65
     66        $wp_upload_dir = \wp_upload_dir();
     67        $wp_upload_dir['local_path'] = $wp_upload_dir['path'];
     68        $wp_upload_dir['local_basedir'] = $wp_upload_dir['basedir'];
     69        $wp_upload_dir['path'] = $this->convert_to_s3_path($wp_upload_dir['path']);
     70        $wp_upload_dir['basedir'] = $this->convert_to_s3_path($wp_upload_dir['basedir']);
     71        $this->wp_upload_dir = $wp_upload_dir;
    6672       
    6773        $this->db = new AsssuDb($this, $wpdb);
     
    152158        return $this->config['version'];
    153159    }
     160   
     161    function upgrade_1_9_3() {
     162        $this->config['version'] = '1.9.4';
     163        $this->db->save_config();
     164        return $this->config['version'];
     165    }
    154166
    155167    function convert_to_s3_path($path, $stream_wrapper_format=true) {
    156168        if (strpos($path, 's3://') === 0)
    157169            return $path;
    158         $s3_path = trim(str_replace($this->wp_upload_dir['basedir'], '', $path), '/');
     170        $s3_path = trim(str_replace($this->wp_upload_dir['local_basedir'], '', $path), '/');
    159171        if (!empty($this->config['bucket_subdir']))
    160172            $s3_path = trim($this->config['bucket_subdir'].'/'.$s3_path, '/');
     
    198210            $amazon_path = sprintf('%s%s/', $amazon_path, $this->config['bucket_subdir']);
    199211
    200         $htaccess_file = $this->wp_upload_dir['basedir'].'/.htaccess';
     212        $htaccess_file = $this->wp_upload_dir['local_basedir'].'/.htaccess';
    201213
    202214        ob_start();
     
    239251
    240252    function action_cron() {
    241         list($limit, $files) = $this->find_files($this->asssu->wp_upload_dir['basedir'], 50);
     253        list($limit, $files) = $this->find_files($this->asssu->wp_upload_dir['local_basedir'], 50);
    242254        if (count($files) > 0)
    243255            $client = $this->asssu->get_s3_client();
     
    292304    function __construct($asssu) {
    293305        $this->asssu = $asssu;
    294         // \add_filter('upload_dir', array($this, 'upload_dir'));
    295         \add_filter('wp_handle_upload_prefilter', array($this, 'wp_handle_upload_prefilter'));
    296         \add_filter('wp_delete_file', array($this, 'wp_delete_file'));
     306        // \add_filter('upload_dir', array($this, 'upload_dir'), 20);
     307        // \add_filter('wp_handle_upload', array($this, 'wp_handle_upload'), 20);
     308        // \add_filter('image_make_intermediate_size', array($this, 'image_make_intermediate_size'), 20);
     309        \add_filter('wp_handle_upload_prefilter', array($this, 'wp_handle_upload_prefilter'), 20);
     310        \add_filter('wp_delete_file', array($this, 'wp_delete_file'), 20);
    297311    }
    298312
    299313    function upload_dir($args) {
    300314        $client = $this->asssu->get_s3_client();
     315        $args['local_path'] = $args['path'];
     316        $args['local_basedir'] = $args['basedir'];
    301317        $args['path'] = $this->asssu->convert_to_s3_path($args['path']);
    302318        $args['basedir'] = $this->asssu->convert_to_s3_path($args['basedir']);
     319        if (!file_exists($args['path']))
     320            file_put_contents($args['path'].'/index', '');
    303321        return $args;
     322    }
     323
     324    function wp_handle_upload($options) {
     325        $client = $this->asssu->get_s3_client();
     326        list($wrapper, $key) = explode($this->asssu->config['bucket_name'], $options['file']);
     327        $result = $client->putObjectAcl(array(
     328            'Bucket' => $this->asssu->config['bucket_name'],
     329            'Key'    => $key,
     330            'ACL'    => 'public-read'
     331        ));
     332        return $options;
     333    }
     334
     335    function image_make_intermediate_size($filename) {
     336        $client = $this->asssu->get_s3_client();
     337        list($wrapper, $key) = explode($this->asssu->config['bucket_name'], $filename);
     338        $result = $client->putObjectAcl(array(
     339            'Bucket' => $this->asssu->config['bucket_name'],
     340            'Key'    => $key,
     341            'ACL'    => 'public-read'
     342        ));
     343        return $filename;
    304344    }
    305345
     
    311351    function wp_unique_filename($filename) {
    312352        $client = $this->asssu->get_s3_client();
    313         $path = $this->asssu->wp_upload_dir['path'];
    314         $s3_path = $this->asssu->convert_to_s3_path($this->asssu->wp_upload_dir['path']);
     353        $path = $this->asssu->wp_upload_dir['local_path'];
     354        $s3_path = $this->asssu->wp_upload_dir['path'];
    315355        $filename = str_replace('+', '-', $filename);
    316356       
     
    397437            'Amazon S3 Uploads',
    398438            'manage_options',
    399             'options',
     439            'amazon-s3-uploads-options',
    400440            array($this, 'page_options')
    401441        );
     
    405445                'Amazon S3 Uploads Test Corn',
    406446                'manage_options',
    407                 'test_cron',
     447                'amazon-s3-uploads-test_cron',
    408448                array($this, 'test_cron')
    409449            );
     
    412452                'Amazon S3 Uploads Test Bucket Location',
    413453                'manage_options',
    414                 'test_bucket_location',
     454                'amazon-s3-uploads-test_bucket_location',
    415455                array($this, 'test_bucket_location')
    416456            );
  • amazon-s3-uploads/trunk/plugin/asssu/forms.php

    r729295 r737670  
    117117        'eu-west-1'         => 'eu-west-1',
    118118        'ap-southeast-1'    => 'ap-southeast-1',
     119        'ap-southeast-2'    => 'ap-southeast-2',
    119120        'ap-northeast-1'    => 'ap-northeast-1',
    120121        'sa-east-1'         => 'sa-east-1'
     
    126127        'eu-west-1'         => 'eu-west-1',
    127128        'ap-southeast-1'    => 'ap-southeast-1',
     129        'ap-southeast-2'    => 'ap-southeast-2',
    128130        'ap-northeast-1'    => 'ap-northeast-1',
    129131        'sa-east-1'         => 'sa-east-1'
  • amazon-s3-uploads/trunk/readme.txt

    r730022 r737670  
    55Requires at least: 3.5.2
    66Tested up to: 3.5.2
    7 Stable tag: 1.9.3
     7Stable tag: 1.9.4
    88License: GPLv2.1
    99
     
    2121REQUIREMENTS
    2222
    23 *   Wordpress 3.5.1+
     23*   Wordpress 3.5.2+
    2424*   PHP 5.3.3+ compiled with the cURL extension
    2525*   A recent version of cURL 7.16.2+ compiled with OpenSSL and zlib
Note: See TracChangeset for help on using the changeset viewer.