We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose cells workbook to save in AWS S3 bucket as pdf format

Hi Team,

I’ve tried to save the weeklyFlashReport.Save(path, SaveFormat.Pdf);
path - S3 bucket folder name.

When i tried to save - getting below exception - Message:‘Could not find a part of the path ‘/var/task/FlashReport/FlashReport_2/10/20 10:21:43 AM.pdf’.’ when writing an object

Path is looking at local system directory and not S3 object. Please help me out.



Thanks for your query.

Well, this is not an issue with Aspose.Cells APIs as you cannot directly pass S3 objects to Aspose APIs. Even you cannot do that by directly using System.IO APIs (for read/write files) only (without involving Aspose.Cells APIs). However you can load S3 objects into a byte array (Java example) and then pass to Aspose APIs for PDF conversion. Once the conversion is done, you can upload the converted stream back to S3.

Please note, Aspose.Cells allows you to save to on a disk or to stream that you have to use your own code to upload/save to your desired place. Please note, saving output streams to S3 bucket is beyond scope of Aspose.Cells APIs.

Hope, this helps a bit.

I tried the same by getting xlsx data into byte array and passing that byte array to upload it in s3. For excel it is working. The same i tried with PDF, getting “The type Initializer “” throws an exception”

weeklyFlashReport.Save(inputStream, SaveFormat.Xlsx);
buffer = inputStream.ToArray();
outputStream.Write(buffer, 0, buffer.Length);
Console.WriteLine(“Put object request starts”);
var putRequest = new Amazon.S3.Model.PutObjectRequest
BucketName = bucketName,
ContentType = “application/vnd.openxmlformats-officedocument.spreadsheetml.sheet”,
InputStream = outputStream,
Key = path,
CannedACL = S3CannedACL.PublicRead

                Console.WriteLine("Put Object request ends");

                Task<PutObjectResponse> response = client.PutObjectAsync(putRequest);

                GetPreSignedUrlRequest request = new GetPreSignedUrlRequest();
                request.BucketName = bucketName;
                request.Key = path;
                request.Expires = DateTime.Now.AddMinutes(10);
                request.Protocol = Protocol.HTTP;
                url = client.GetPreSignedURL(request);

Please help me.

Thanks in advance.


Good to know that your original issue is sorted out now.
For your current issue, you need to install libgdiplus as Aspose.Cells requires this ibrary for rendering features (e.g you may use linux box to run the command lines):

apt-get update
apt-get install -y libgdiplus
cd /usr/lib && ln -s libgdiplus.so gdiplus.dll

And install libc6-dev:

apt-get install -y --no-install-recommends libc6-dev

Hope, this helps a bit.