By Talha Sword
Hello,
I upload image from c# rest api to digital ocean space. And I use Awssdk.S3 (3.5.2.1)
I’ve been getting an upload error for a while.
ErrorCode : InvalidArgument
ErrorMessage: Error making request with Error Code InvalidArgument and Http Status Code BadRequest. No further error information was returned by the service.
Why might be getting an error?
public bool UploadImage(StoreId storeId, string type, string subType, string fileName, string base64String)
{
var s3ClientConfig = new AmazonS3Config { ServiceURL = endpointUrl };
s3Client = new AmazonS3Client(s3ClientConfig);
byte[] bytes = Convert.FromBase64String(base64String);
try
{
var fileTransferUtility = new TransferUtility(s3Client);
var fileTransferUtilityRequest = new TransferUtilityUploadRequest
{
BucketName = bucketName + @"/" + appSettings.Environment + @"/" + storeId.ToString() + @"/" + type,
//FilePath = filePath,
StorageClass = S3StorageClass.StandardInfrequentAccess,
PartSize = 6291456, // 6 MB
Key = fileName + extension,
CannedACL = S3CannedACL.PublicRead,
};
using (var ms = new MemoryStream(bytes))
{
fileTransferUtilityRequest.InputStream = ms;
fileTransferUtility.Upload(fileTransferUtilityRequest);
}
return true;
}
catch (AmazonS3Exception e)
{
logger.Error(string.Format("DigitalOcean Upload Method Error*** ErrorCode: {0} -- Message: {1}", e.ErrorCode, e.Message));
}
return false;
}
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Excuse me, I got the same problem but I don’t know how ti solve it. Could someone help me? Thx
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.