finkinfridom / payload-cloudinary-plugin

Upload media to Cloudinary service
MIT License
57 stars 3 forks source link

Errno: -4058 code ENOENT #130

Closed swordensen closed 9 months ago

swordensen commented 9 months ago

Hi guys,

I am trying out this cloudinary plugin but, I am having trouble getting it to work.

I am receiving the following error:

    at D:\projects\personal-website\node_modules\payload-cloudinary-plugin\dist\plugins\cloudinaryPlugin.js:127:23
    at step (D:\projects\personal-website\node_modules\payload-cloudinary-plugin\dist\plugins\cloudinaryPlugin.js:44:23)
    at Object.throw (D:\projects\personal-website\node_modules\payload-cloudinary-plugin\dist\plugins\cloudinaryPlugin.js:25:53)
    at rejected (D:\projects\personal-website\node_modules\payload-cloudinary-plugin\dist\plugins\cloudinaryPlugin.js:17:65)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

I think it's trying to upload the file I am adding to payload before it's every hitting the media directory which is causing it to throw a file not existing error.

My config is set up as directed to the readme.md and my credentials work:

server.ts

const server = express();
const cloudinaryConfig = cloudinary.config({
  cloud_name: '********',
  api_key: '********'',
  api_secret: '********'',
});

server.use(mediaManagement(cloudinaryConfig));

payload.config.ts


.
.
.
  plugins: [
    formBuilder({
      redirectRelationships: [
        'pages',
      ],
    }),
    cloudinaryPlugin(),
  ],
});

thanks for looking into this issue!

swordensen commented 9 months ago

disabling localStorage in the payload collection config ended up solving my problem.

this isn't documented anywhere and the cloudinaryService looks like it tries to handle the image saving so maybe this is still a bug?

Jonashr commented 9 months ago

Same error happening here. Appeared out of nowhere a few days ago, had been working in production until then. Haven't upgraded dependencies on version 2.0.15 of payload. Upgraded to 2.5.0 and it didn't do anything.

Here is an example error message:

[13:04:08] ERROR (payload): APIError: Cloudinary: {"error":{"errno":-2,"code":"ENOENT","syscall":"open","path":"/home/node/media/300_balloon_desktop.png"}} at /home/node/app/node_modules/payload-cloudinary-plugin/dist/plugins/cloudinaryPlugin.js:126:23 at step (/home/node/app/node_modules/payload-cloudinary-plugin/dist/plugins/cloudinaryPlugin.js:44:23) at Object.throw (/home/node/app/node_modules/payload-cloudinary-plugin/dist/plugins/cloudinaryPlugin.js:25:53) at rejected (/home/node/app/node_modules/payload-cloudinary-plugin/dist/plugins/cloudinaryPlugin.js:17:65) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

finkinfridom commented 9 months ago

I'll have a look and let you know ASAP Thanks for reporting.

@swordensen could you please give me the payload and the plugin version you're using? @Jonashr, if you want, feel free to post your versions too.

swordensen commented 9 months ago

cloudinary plugin version: ^0.1.1 payload version: ^2.5.0

here are my package.json dependencies

"@lexical/clipboard": "0.12.5", "@payloadcms/bundler-webpack": "^1.0.5", "@payloadcms/db-postgres": "^0.2.2", "@payloadcms/next-payload": "^0.1.11", "@payloadcms/plugin-cloud-storage": "^1.1.1", "@payloadcms/plugin-form-builder": "^1.1.0", "@payloadcms/richtext-lexical": "^0.5.0", "@types/express-fileupload": "^1.4.1", "cloudinary": "^1.41.1", "copyfiles": "^2.4.1", "critters": "^0.0.18", "dotenv": "^16.0.0", "escape-html": "^1.0.3", "eslint-config-next": "^14.0.4", "express": "^4.18.0", "next": "^14.0.4", "payload": "^2.5.0", "payload-cloudinary-plugin": "^0.1.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-hook-form": "^7.43.9", "react-icons": "^4.8.0", "react-intersection-observer": "^9.4.4", "sass": "^1.52.0", "typescript": "^5.1.3", "util": "^0.12.5", "yjs": "^13.6.10"

finkinfridom commented 9 months ago

I just noticed the issue raised after this PR from the payload repo: https://github.com/payloadcms/payload/pull/4218 Just checking if there's an easy fix to avoid issues for the future.

finkinfridom commented 9 months ago

Created PR: https://github.com/finkinfridom/payload-cloudinary-plugin/pull/138

finkinfridom commented 9 months ago

Just released v0.1.2