New feature upload folder for Strapi did not work

Hi, I may be doing something wrong, however, i put the upload path in the settings for the web app, and run an update/deployment for Strapi v3. Lost all the links to the media fields

Not sure if the upload field can be updated after the initial deployment.

Please clarify.

regards

Hello @Karlomac01,

I’m sorry but what is the case exactly? Did you change the default uploads directory of strapi which is public/uploads to something of your own?

Or, you made a deployment and then uploaded some files and in the next deployment your uploaded files weren’t available in the site?

Hi Anish,

Here is how it happened:

  1. I previously deployed Strapi v4 using Cleavr before your team released the persistent storage feature for strapi and directus
  2. I was uploading photos and videos from my app to strapi v4 with no problems
  3. I am aware of the existing issue that uploads will be “unlinked” from strapi or directus when they are re-deployed using cleavr
  4. When it was announced sometime last week of the persistent storage, i decided to try and see if it will affect my existing installtion
  5. I reconfigured the build settings of FILE UPLOAD PATH to : public/uploads
  6. after making sure the file upload path had the correct info, i redeployed the server using cleavr.
  7. after a successful deploy, i accessed my application and all upload files were now broken links.

Thats why i was asking if FILE UPLOAD PATH should be configured before deploying strapi for the first time? or the process i did above should have kept the links together?

I hope this is clear.

regards,

Hello @Karlomac01,

I got it, and that’s crystal clear.

I’m afraid you’ll have to copy the files from an older deployment (which has files) to the directory where we store files. Let us know if you need any help with this (we can share with you some commands).

Except for that case, any deployments made after setting up the FILE UPLOAD PATH should persist files.

We’re already discussing how we can handle this edge case as well. Thank you for bringing it to our notice.

hi anish,

thank you for the information. So basically, for now, we need to define the upload path BEFORE initial deployment.

I would appreciate your help in moving the uploaded files to the current deployed instance with some commands. I have some linux skills so i think i can handle a few commands :slight_smile:

thank you again for your continued support.

@Karlomac01 you can use my unofficial persistent storage script. This also copies the files and dirs to a persistent storage dir from the previous deployment (which is linked by the way in the “current” folder until the current deployment finishes). You could adjust the arguments or reverse engineer it and make a own version that only copy the files to the official persistent storage dir. The script is here, I’ve been through this struggle already :laughing: :v:

1 Like

Don’t know if this helps but i also have an upload folder that i want to keep outside the deploy versioning and i got help to create a deployment hook:

SHARED_DIR=upload
echo 'Checking the shared directory...'
if [ -d "{{ projectPath }}/$SHARED_DIR" ]; then
  echo 'Found an existing shared directory.'
else
  mkdir -p "{{ projectPath }}/$SHARED_DIR"
  chown -R {{ username }}:www-data "{{ projectPath }}/$SHARED_DIR"
  chmod -R 775 "{{ projectPath }}/$SHARED_DIR"
fi

# remove the storage folder if exists
if [ -d "{{ releasePath }}/public/$SHARED_DIR" ]; then
    echo "Shared directory {{ releasePath }}/public/$SHARED_DIR is pushed. To make data persists across deployments, removing this directory and linking it to {{ projectPath }}/$SHARED_DIR instead."
    rm -rf "{{ releasePath }}/public/$SHARED_DIR"
fi

echo 'Linking the shared folder...'
ln -s "{{ projectPath }}/$SHARED_DIR" "{{ releasePath }}/public/$SHARED_DIR"

Have a nice day

1 Like

Hello @Karlomac01,

You need to do the following things:

  1. SSH into the server and change directory to /home/server-user/site-name/releases. This folder contains deployments you’ve made.
  2. Now locate which of your release’s public/uploads has all the files you’ve uploaded in your app.
  3. Once you’ve figured out which release consists the uploaded files note the release name and execute the following command

mv -v /home/server-user/site-name/release-name/public/uploads/* /home/server-user/site-name/uploads