SAAS-531: Finalize S3 folder hierarchy
This commit is contained in:
parent
ad16683858
commit
02e4c18931
2 changed files with 18 additions and 4 deletions
|
@ -113,10 +113,14 @@ class Application_Model_RabbitMq
|
||||||
// Pro stations will share the same bucket.
|
// Pro stations will share the same bucket.
|
||||||
$data['station_domain'] = $stationDomain = Application_Model_Preference::GetStationName();
|
$data['station_domain'] = $stationDomain = Application_Model_Preference::GetStationName();
|
||||||
|
|
||||||
// Each file uploaded to cloud storage is prefixed with the station's
|
// We add a prefix to the resource name so files are not all placed
|
||||||
// hosting id.
|
// under the root folder. We do this in case we need to restore a
|
||||||
|
// customer's file/s; File restoration is done via the S3 Browser
|
||||||
|
// client. The client will hang if there are too many files under the
|
||||||
|
// same folder.
|
||||||
$clientCurrentAirtimeProduct = BillingController::getClientCurrentAirtimeProduct();
|
$clientCurrentAirtimeProduct = BillingController::getClientCurrentAirtimeProduct();
|
||||||
$data['file_prefix'] = $clientCurrentAirtimeProduct["id"];
|
$hostingId = $clientCurrentAirtimeProduct["id"];
|
||||||
|
$data['file_prefix'] = substr($hostingId, -2)."/".$hostingId;
|
||||||
|
|
||||||
$jsonData = json_encode($data);
|
$jsonData = json_encode($data);
|
||||||
//self::sendMessage($exchange, 'topic', false, $jsonData, 'airtime-uploads');
|
//self::sendMessage($exchange, 'topic', false, $jsonData, 'airtime-uploads');
|
||||||
|
|
|
@ -74,7 +74,17 @@ class CloudStorageUploader:
|
||||||
# in the object name. URL encoding the object name doesn't solve the
|
# in the object name. URL encoding the object name doesn't solve the
|
||||||
# problem. As a solution we will replace spaces with dashes.
|
# problem. As a solution we will replace spaces with dashes.
|
||||||
file_name = file_name.replace(" ", "-")
|
file_name = file_name.replace(" ", "-")
|
||||||
resource_id = "%s/%s_%s%s" % (metadata["file_prefix"], file_name, str(uuid.uuid4()), extension)
|
|
||||||
|
unique_id = str(uuid.uuid4())
|
||||||
|
|
||||||
|
# We add another prefix to the resource name with the last two characters
|
||||||
|
# of the unique id so files are not all placed under the root folder. We
|
||||||
|
# do this in case we need to restore a customer's file/s; File restoration
|
||||||
|
# is done via the S3 Browser client. The client will hang if there are too
|
||||||
|
# many files under the same folder.
|
||||||
|
unique_id_prefix = unique_id[-2:]
|
||||||
|
|
||||||
|
resource_id = "%s/%s/%s_%s%s" % (metadata['file_prefix'], unique_id_prefix, file_name, unique_id, extension)
|
||||||
|
|
||||||
conn = S3Connection(self._api_key, self._api_key_secret, host=self._host)
|
conn = S3Connection(self._api_key, self._api_key_secret, host=self._host)
|
||||||
bucket = conn.get_bucket(self._bucket)
|
bucket = conn.get_bucket(self._bucket)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue