Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions src/TaskManager/TaskManager/TaskManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ private async Task HandleDispatchTask(JsonMessage<TaskDispatchEvent> message)

try
{
if (PluginStrings.PlugsRequiresPermanentAccoutns.Contains(
if (PluginStrings.PlugsRequiresPermanentAccounts.Contains(
message.Body.TaskPluginType,
StringComparer.InvariantCultureIgnoreCase))
{
Expand Down Expand Up @@ -559,7 +559,13 @@ private async Task PopulateTemporaryStorageCredentials(params Messaging.Common.S

foreach (var storage in storages)
{
var credentials = await _storageService.CreateTemporaryCredentialsAsync(storage.Bucket, storage.RelativeRootPath, _options.Value.TaskManager.TemporaryStorageCredentialDurationSeconds, _cancellationToken).ConfigureAwait(false);
var credentials = await _storageService.CreateTemporaryCredentialsAsync(
storage.Bucket,
ShortenStoragePath(storage.RelativeRootPath),
_options.Value.TaskManager.TemporaryStorageCredentialDurationSeconds,
_cancellationToken)
.ConfigureAwait(false);

storage.Credentials = new Credentials
{
AccessKey = credentials.AccessKeyId,
Expand All @@ -569,6 +575,19 @@ private async Task PopulateTemporaryStorageCredentials(params Messaging.Common.S
}
}

// added because AWS s3 policy creation is by defualt limited to 2048 characters, which
// can easily be surpassed with long multipart path names.
private string ShortenStoragePath(string path)
{
var pathParts = path.Split('/');
if (pathParts.Length <= 3)
{
return path;
}

return $"{pathParts[0]}/{pathParts[1]}/{pathParts[2]}";
}

private void AcknowledgeMessage<T>(JsonMessage<T> message)
{
Guard.Against.NullService(_messageBrokerSubscriberService, nameof(IMessageBrokerSubscriberService));
Expand Down