Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

I am experiences problems accessing files on DigitalOcean Spaces in situations where the target file contains whitespace in its name. The below function works perfectly for private files without whitespace in the filename.
I am using .Net Core 2.1 and the AWSSDK.S3 package for access through the S3 API.
My code for retrieval (which works for all files containing no whitespace):
public async Task<Stream> GetReadStream()
{
// Placed here for completeness
this.client = new AmazonS3Client(options.Key, options.Secret, new AmazonS3Config { ServiceURL = options.Url });
MemoryStream result = new MemoryStream();
try
{
GetObjectRequest request = new GetObjectRequest
{
BucketName = options.Bucket,
Key = "folder/file with space.zip"
};
using (GetObjectResponse response = await client.GetObjectAsync(request))
using (Stream responseStream = response.ResponseStream)
{
responseStream.CopyTo(result);
}
}
catch (AmazonS3Exception e)
{
Console.WriteLine("Error encountered ***. Message:'{0}' when reading an object", e.Message);
}
catch (Exception e)
{
Console.WriteLine("Unknown encountered on server. Message:'{0}' when reading an object", e.Message);
}
result.Seek(0, SeekOrigin.Begin);
return result;
}
From the log I can see that the AWS SDK URL encodes the filename to: “file%20with%20space.zip” and the resulting URL is identical to that found by browsing the file through the DO Dashboard and copying an URL from the file directly.
Reading this post I suspect the problem happens to any private file containing any character needing URL encoding.
Have I done something wrong or is there any solution to this problem apart from avoiding filenames requiring URL encoding?
Thank you in advance for your time.
009fd274aeae48f2bfbda6ef568676
009fd274aeae48f2bfbda6ef568676
SarkariResultht
Arne van Hoorn
4287c71658bd4ea39bef277d491b1c
4287c71658bd4ea39bef277d491b1c
Demanix
Demanix
Henry Mui
Prakash Hinduja
f60f754977ec49e1b2cad3cf42286e
anonymouse1