[self hosting] [words.cloud] configure aws s3 as storage via docker container

Hi all

I am trying to configure aspose for docx to pdf conversion. for that I will require to configure aspose to read from s3 and write to s3 after conversion. I couldn’t find a configuration where I could set the storage config in docker container or api to create storage on the fly

is there a implementation where I can specify storage config in the container level or create via api

  • storage name
  • bucket name
  • aws key
  • aws secret

alternative is to

  • download docx from s3
  • upload to aspose
  • convert to pdf
  • download from aspose
  • upload to s3

alternative approach is really inefficient, so I am wondering whether the above mentioned configuration is possible

thanks in advance

@vinujan

I am afraid currently, Aspose.Words Cloud Docker image supports local storage. However, we have logged an enhancement ticket(WORDSCLOUD-2679) to support the configuration of AWS S3 storage in a Docker container.

Please note that you can configure your local folder as a storage volume.

docker run -p 8000:80 -e "LicensePublicKey=asposeforcloudxxxxxxx" -e "LicensePrivateKey=G21xxxxx298E_" -e "User=tilalahmad" -e "Password=1234567890" -v "I:/Aspose/Docker/fonts:/fonts" -v "I:/Aspose/Docker/data:/data" --name aw_241 aspose/words-cloud:24.1

Furthermore, you can convert your files from the request body and get output in response without using any cloud storage. Please check the following documentation for details.

1 Like

@tilal.ahmad

Thank you very much for the info. Noted on the enhancement.

1 Like

@tilal.ahmad I am getting Error: Authorization failed when calling the conversion api in docker container. Please help.

Update

  • when enabled debug log I am getting "Username or password is incorrect", but I have configured username and password but not license details as I am trying to evaluate aspose in trial mode

Thank you

@vinujan

Please share your script to run the Aspose.Words Cloud Docker image and sample code for calling the conversion API. We will look into it and guide you accordingly.

1 Like

@tilal.ahmad

This is the client code (asposewordscloud@24.3.0)

export default class AsposeWordService {
    private wordsApi: WordsApi;

    constructor() {
        this.wordsApi = new WordsApi('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 'xxxxxxxx', 'http://localhost:9090', true);
    }

    convertToDocx = async (file: Express.Multer.File) => {
        const fileName = file.originalname ?? file.filename

        try {

            const requestDocument = Readable.from(file.buffer);
            const convertRequest = new ConvertDocumentRequest({
                document: requestDocument,
                format: "pdf"
            })

            const convertResult = await this.wordsApi.convertDocument(convertRequest);
            return convertResult.body
        } catch (e) {
            console.error('error while converting document.', e)
            throw new Error('Error while converting document ')
        }

    };

};

kubenetes pod configuration

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "6"
    meta.helm.sh/release-name: dev-aspose-word
    meta.helm.sh/release-namespace: default
  creationTimestamp: "2024-04-05T07:38:17Z"
  generation: 6
  labels:
    app.kubernetes.io/instance: dev-aspose-word
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: service
    app.kubernetes.io/version: 1.16.0
    helm.sh/chart: service-0.1.3
  name: dev-aspose-word-service
  namespace: default
  resourceVersion: "140158859"
  uid: 338f469c-6109-4a95-8886-1036bc2c5dc7
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app.kubernetes.io/instance: dev-aspose-word
      app.kubernetes.io/name: service
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app.kubernetes.io/instance: dev-aspose-word
        app.kubernetes.io/managed-by: Helm
        app.kubernetes.io/name: service
        app.kubernetes.io/version: 1.16.0
        helm.sh/chart: service-0.1.3
    spec:
      containers:
      - env:
        - name: User
          value: xxxx
        - name: Password
          value: xxxxxx
        image: aspose/words-cloud:24.3
        imagePullPolicy: IfNotPresent
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /
            port: http
            scheme: HTTP
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        name: service
        ports:
        - containerPort: 80
          name: http
          protocol: TCP
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /
            port: http
            scheme: HTTP
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        resources: {}
        securityContext: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      serviceAccount: dev-aspose-word-service
      serviceAccountName: dev-aspose-word-service
      terminationGracePeriodSeconds: 30
status:
  availableReplicas: 1
  conditions:
  - lastTransitionTime: "2024-04-06T04:16:58Z"
    lastUpdateTime: "2024-04-06T04:16:58Z"
    message: Deployment has minimum availability.
    reason: MinimumReplicasAvailable
    status: "True"
    type: Available
  - lastTransitionTime: "2024-04-05T07:38:17Z"
    lastUpdateTime: "2024-04-08T03:10:01Z"
    message: ReplicaSet "dev-aspose-word-service-67b6f989bf" has successfully progressed.
    reason: NewReplicaSetAvailable
    status: "True"
    type: Progressing
  observedGeneration: 6
  readyReplicas: 1
  replicas: 1
  updatedReplicas: 1

debug output

{
  "request": {
    "debugId": 1,
    "uri": "http://localhost:9090/v4.0/words/connect/token",
    "method": "POST",
    "headers": {
      "x-aspose-client": "nodejs sdk",
      "x-aspose-client-version": "24.3",
      "host": "localhost:9090",
      "content-type": "application/x-www-form-urlencoded",
      "accept": "application/json",
      "content-length": 123
    },
    "body": "grant_type=client_credentials&client_id=xxxx&client_secret=xxxx"
  }
}
{
  "response": {
    "debugId": 1,
    "headers": {
      "content-length": "52",
      "connection": "close",
      "content-type": "application/json; charset=utf-8",
      "date": "Mon, 08 Apr 2024 03:40:50 GMT",
      "server": "Kestrel",
      "api-supported-versions": "4.0"
    },
    "statusCode": 400,
    "body": {
      "message": "Username or password is incorrect"
    }
  }
}
error while converting document. Error: Authorization failed
    at /xxxxx/pocs/aspose-words-client/node_modules/asposewordscloud/dist/internal/requestHelper.js:149:23
    at Generator.throw (<anonymous>)
    at rejected (/xxxxx/pocs/aspose-words-client/node_modules/asposewordscloud/dist/internal/requestHelper.js:32:65)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

thank you

@vinujan

Please note that if “License” parameters are omitted, the app will work in trial mode. I am unable to notice any issues while testing the scenario without setting license parameters. Please find the sample code and output file for reference.

docker run -p 8000:80 -e "User=tilalahmad" -e "Password=1234567890" -v "I:/Aspose/Docker/fonts:/fonts" -v "I:/Aspose/Docker/data:/data" --name aw_243 aspose/words-cloud:24.3
const {WordsApi, ConvertDocumentRequest } = require("asposewordscloud");
var fs = require('fs');

const convertDocument = async () => {

try {

const clientId = "tilalahmad";
        const secret = "1234567890";
        const asposeEndpoint = "http://localhost:8000";
        const wordsApi = new WordsApi(clientId, secret, asposeEndpoint);
        const requestDocument = fs.createReadStream("input.docx");
        const convertRequest = new ConvertDocumentRequest({
                                                   format: "pdf",
                                                  document: requestDocument
        });

let convertRequestResult = await wordsApi.convertDocument(convertRequest);
fs.writeFileSync("output.pdf", convertRequestResult.body);
console.log(convertRequestResult);

} catch (err) {
throw err;
}
}

convertDocument()
.then(() => {
console.log("Document converted successfully");
})
.catch((err) => {
console.log("Error occurred while converting the PDF document:", err);
})

output.pdf (378.6 KB)

@tilal.ahmad

Thank you very much for the sample code. I was able to convert the document.

it is clientId and clientSecret wrong in my case. I used the clientId and clientSecret from application https://dashboard.aspose.cloud/applications created instead of username and password.

it would be great if the documents could point out this exception for self-hosting.

@tilal.ahmad

Is there a document regarding required minimum resources (cpu and memory) for self-hosting aspose cloud word.

also, please help reference any benchmark(resource allocation vs throughput) outcome against the resources if any.

thanks in advance.

@vinujan

Thanks for the suggestion. We have logged a ticket(WORDSCLOUD-2681) to update the documentation and will update it as soon as possible.

1 Like

I am afraid we don’t have any benchmark, and for minimum requirements and overall consumption, it highly depends on the document structure. If the document is small and not complex, there will be no high load on the container, but if the document is big and complex, it may consume lots of resources.

1 Like

Thank you very much @tilal.ahmad

1 Like

The issues you have found earlier (filed as WORDSCLOUD-2679) have been fixed in this update. This message was posted using Bugs notification tool by Ivanov_John