Loading inc/class-s3-uploads-wp-cli-command.php +51 −11 Original line number Diff line number Diff line Loading @@ -3,6 +3,46 @@ class S3_Uploads_WP_CLI_Command extends WP_CLI_Command { /** * Verifies the API keys entered will work for reading, writing, etc. * * @subcommand verify **/ public function verify_api_keys() { S3_Uploads::get_instance(); // Boot $upload_dir = wp_upload_dir(); // The upload file location on the local filesystem $s3_path = $upload_dir['basedir'] . '/' . mt_rand() . '.jpg'; // Attempt to copy the file to S3 WP_CLI::print_value( 'Uploading file '. $s3_path ); $copy = copy( dirname( dirname(__FILE__) ) . '/tests/data/canola.jpg', $s3_path ); // Check if copy worked if ( ! $copy ) { WP_CLI::error( 'Failed to copy '. $s3_path ); return; } // Delete off S3 WP_CLI::print_value( 'Deleting file '. $s3_path ); $delete = unlink( $s3_path ); // Check that delete worked if ( ! $delete ) { WP_CLI::error( 'Failed to delete '. $s3_path ); return; } WP_CLI::success( 'Success' ); } /** * @subcommand migrate-attachments * @synopsis [--delete-local] */ Loading Loading
inc/class-s3-uploads-wp-cli-command.php +51 −11 Original line number Diff line number Diff line Loading @@ -3,6 +3,46 @@ class S3_Uploads_WP_CLI_Command extends WP_CLI_Command { /** * Verifies the API keys entered will work for reading, writing, etc. * * @subcommand verify **/ public function verify_api_keys() { S3_Uploads::get_instance(); // Boot $upload_dir = wp_upload_dir(); // The upload file location on the local filesystem $s3_path = $upload_dir['basedir'] . '/' . mt_rand() . '.jpg'; // Attempt to copy the file to S3 WP_CLI::print_value( 'Uploading file '. $s3_path ); $copy = copy( dirname( dirname(__FILE__) ) . '/tests/data/canola.jpg', $s3_path ); // Check if copy worked if ( ! $copy ) { WP_CLI::error( 'Failed to copy '. $s3_path ); return; } // Delete off S3 WP_CLI::print_value( 'Deleting file '. $s3_path ); $delete = unlink( $s3_path ); // Check that delete worked if ( ! $delete ) { WP_CLI::error( 'Failed to delete '. $s3_path ); return; } WP_CLI::success( 'Success' ); } /** * @subcommand migrate-attachments * @synopsis [--delete-local] */ Loading