strapi-community / strapi-provider-upload-google-cloud-storage

Google Cloud Storage Upload Provider for Strapi
MIT License
211 stars 94 forks source link

ENOTEMPTY: directory not empty, rmdir 'C:\Users\username\AppData\Local\Temp\strapi-upload-7bn8Rr' #151

Closed neural-loop closed 1 year ago

neural-loop commented 2 years ago

Describe the bug Uploading through Strapi UI the first image and the files are successfully uploaded into GC, however it errors out and doesn't seem to recognize what is going on

To Reproduce

  1. Install and configure storage cloud
  2. upload image

Expected behavior Success entry to library

Screenshots image image image image

Desktop (please complete the following information):

tudor0 commented 1 year ago

Hi, I was having the same issues, this happened to me when I would try to upload a picture with the same name twice. Could this be your case as well?

neural-loop commented 1 year ago

@tudor0 I think the issue was CORS .

tudor0 commented 1 year ago

@neural-loop Where should the cors settings be placed at?

tudor0 commented 1 year ago

Or even, do you have an example I could maybe follow?

Thanks in advance

neural-loop commented 1 year ago

image

In the middleware.js

that doesn't match this error message though.. I don't remember exactly what it was that fixed this

server.js

module.exports = ({ env }) => ({
    host: env(process.env.HOST, '0.0.0.0'),
    url: process.env.CLOUD_URL,
});

middleware.js

    config: {
      contentSecurityPolicy: {
        useDefaults: true,
        directives: {
          'connect-src': ["'self'", 'https:'],
          'img-src': ["'self'", 'data:', 'blob:', 'storage.googleapis.com', 'console.cloud.google.com'],
          'media-src': ["'self'", 'data:', 'blob:', 'storage.googleapis.com', 'console.cloud.google.com'],
          upgradeInsecureRequests: null,
        },
      },
    },

plugins.js

  upload: {
    config: {
      provider: "@strapi-community/strapi-provider-upload-google-cloud-storage",
      providerOptions: {
        serviceAccount: process.env.GCS_SERVICE_WORKER,
        bucketName: process.env.GCS_BUCKET_NAME,
        basePath: "media",
        baseUrl: process.env.GCS_BASE_URL,
        publicFiles: true,
        // uniform: env('GCS_UNIFORM'),
      },
    },
  },
tudor0 commented 1 year ago

In middlewares.js, did you configure the strapi::cors or is it just the default?

neural-loop commented 1 year ago

Cors is configured but nothing specific for gcs

tudor0 commented 1 year ago

Does your strapi still upload the pictures locally or just on the cloud? I am comparing my code to yours, but besides some non gcs specific differences, the code is basically the same. You stopped getting that error alltogether?

neural-loop commented 1 year ago

I might still be getting the error, I found that it worked when I deployed - the error I was getting was when I was testing it locally. Maybe it's something in the cloud config?

tudor0 commented 1 year ago

I find it wierd that even though I set the provider as the package, strapi still tries to upload to the local folder. I am guessing that when deployed is does not do that?

neural-loop commented 1 year ago

I think that was the case but I don't remember 100%