Skip to content

Commit

Permalink
Create a folder for the current site in case a bucket is shared betwe…
Browse files Browse the repository at this point in the history
…en multiple sites.

Shorten file name
  • Loading branch information
corsacca committed May 3, 2024
1 parent 5672298 commit f47ffd6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion disciple-tools-storage-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function dt_storage_connections_obj_upload( $response, $storage_connection_id, $
if ( isset( $args['auto_generate_key'] ) && !$args['auto_generate_key'] && !empty( $args['default_key'] ) ) {
$key = $args['default_key'];
} else {
$key = $key_prefix . Disciple_Tools_Storage_API::generate_random_string( 112 );
$key = $key_prefix . Disciple_Tools_Storage_API::generate_random_string( 64 );
}

// If required, capture uploading file's extension.
Expand Down Expand Up @@ -220,6 +220,12 @@ function dt_storage_connections_obj_upload( $response, $storage_connection_id, $
$response = true;
$bucket = $config['bucket'];

//Create a folder for the current site in case a bucket is shared between multiple sites.
$dt_site_id = get_option( 'dt_site_id' );
$site_key = substr( $dt_site_id, 0, 30 );
$key = $site_key . '/' . $key;


// Generate complete file key name to be used moving forward.
$key_name = ( isset( $storage_connection_type['prefix_bucket_name_to_obj_key'] ) && $storage_connection_type['prefix_bucket_name_to_obj_key'] ) ? ( $bucket .'/'. $key ) : $key;

Expand Down

0 comments on commit f47ffd6

Please sign in to comment.