Back

[SOLVED] Server Error

  • 0
  • Self Hosted
  • Storage
xmaniaxz
30 May, 2024, 18:24

Hi, I seem to be running an issue with my UploadFile Script.

It doesnt seem to give an error code back i can actually do something with:

TypeScript
    at _Client.call (webpack-internal:///(action-browser)/./node_modules/node-appwrite/dist/client.js:275:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async _Client.chunkedUpload (webpack-internal:///(action-browser)/./node_modules/node-appwrite/dist/client.js:220:14)
    at async Storage.createFile (webpack-internal:///(action-browser)/./node_modules/node-appwrite/dist/services/storage.js:303:12) {
  code: 500,
  type: 'general_unknown',
  response: {
    message: 'Server Error',
    code: 500,
    type: 'general_unknown',
    version: '1.5.1'
  }
}```
Code where it goes wrong:

```jsx
export async function UploadFile(file) {
  const File = file.get("file");
  const client = await createAdminClient();
  const storage = new Storage(client);
  const fileExists = await CheckIfFileExists(File.name);
  if (!fileExists) {
    const uploadResponse = storage.createFile(
      process.env.NEXT_PUBLIC_BUCKET_ID,
      ID.unique(),
      File
    );
    return uploadResponse.$id;
  } else {
    const files = await storage.listFiles(process.env.NEXT_PUBLIC_BUCKET_ID);
    const existingFile = files.files.find((files) => files.name === File.name);
    return existingFile.$id;
  }
}
TL;DR
The server error was solved by adjusting indentation in the YAML file. An attempt to include ClamAV in the docker-compose.yaml file led to an error regarding the service. Disabling the anti-virus in bucket settings resolved the issue. The PHP script showed an unhandled rejection error with a code of 500 due to a server error.
xmaniaxz
30 May, 2024, 18:25

checked all keys and ID's so that shouldnt be the issue

Binyamin
30 May, 2024, 18:38

Run docker logs appwrite after you're uploading the file for getting the error

xmaniaxz
30 May, 2024, 18:39

Yes i check it out and i get this:

TypeScript
[Error] Timestamp: 2024-05-30T18:38:27+00:00
[Error] Method: POST
[Error] URL: /v1/storage/buckets/:bucketId/files
[Error] Type: RuntimeException
[Error] Message: Unable to connect to ClamAV server
[Error] File: /usr/src/code/vendor/appwrite/php-clamav/src/ClamAV/Network.php
[Error] Line: 66
xmaniaxz
30 May, 2024, 18:40

I dont remember using ClamAV but it might be an internal package?

Binyamin
30 May, 2024, 18:40

You should disable anti-virus in your bucket settings

Binyamin
30 May, 2024, 18:40

Or Enable it in the docker compose

xmaniaxz
30 May, 2024, 18:40

alright. thanks

Binyamin
30 May, 2024, 18:41
TypeScript

  # clamav:
  #   image: appwrite/clamav:1.2.0
  #   container_name: appwrite-clamav
  #   restart: unless-stopped
  #   networks:
  #     - appwrite
  #   volumes:
  #     - appwrite-uploads:/storage/uploads

These commented lines, I'm not sure if it works out-of-the-box though.

xmaniaxz
30 May, 2024, 18:42

ill check ill get back to this. Trying rn

xmaniaxz
30 May, 2024, 18:44

that would be a no services.redis Additional property clamav is not allowed

let me if i can find anytrhing it in the docs

Binyamin
30 May, 2024, 18:46

You should make sure the indented are different So the final results should be like so

TypeScript
  redis:
    image: redis:7.2.4-alpine
    container_name: appwrite-redis
    <<: *x-logging
    restart: unless-stopped
    command: >
      redis-server
      --maxmemory            512mb
      --maxmemory-policy     allkeys-lru
      --maxmemory-samples    5
    networks:
      - appwrite
    volumes:
      - appwrite-redis:/data:rw
  
  clamav:
    image: appwrite/clamav:1.2.0
    container_name: appwrite-clamav
    restart: unless-stopped
    networks:
      - appwrite
    volumes:
      - appwrite-uploads:/storage/uploads
xmaniaxz
30 May, 2024, 18:49

I removed only 1 indent. Turns out i need 2. Checking if it works with the antivirus on

xmaniaxz
30 May, 2024, 18:53

ah well i know where the issue is coming from. So i consider this solved for now. ClamAV seems to be throwing a tantrum though so no antivirus

xmaniaxz
30 May, 2024, 18:54

[SOLVED] Server Error

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more