Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploads use absolute path to files #426

Open
MrCaspan opened this issue Dec 31, 2024 · 1 comment
Open

Uploads use absolute path to files #426

MrCaspan opened this issue Dec 31, 2024 · 1 comment

Comments

@MrCaspan
Copy link

So I have noticed that when you upload a file to Flarum using your tool, if you look at the code for the post it will have something like this:

[upl-image-preview uuid=ebd0eafb-8335-4f46-b3db-2723ccaf07d3 url=https://domain.com/assets/files/2024-12-31/1735616935-268987-img-20181127-155639-193-copy.jpg alt={TEXT?}]

And in the database, the fof_upload_files table if you look at the url column, it is also reverencing the full path.

Is there a reason why you would use the absolute path when storing the file locally? I understand if using a CDN or a 3rd part toool you would need to have a full URL.

I feel like this would cause issues if i ever need to change my domain name or do testing on a dev server..

Thanks all!

@clarkwinkelmann
Copy link
Member

I believe the reason the full URL is stored for local files is indeed because of the cloud adapters. The local adapter is essentially treated like any other cloud adapter, and a URL is stored for compatibility with the other adapters.

The full URL being inserted in the post itself is likewise for compatibility reason. But I believe there was some work in progress to move to the UUID exclusively in the future, as it will allow the adapter to change the URL dynamically if the CDN prefix changes, or for local uploads if the forum host changes.

At the moment, if you change your forum URL you will need to perform a search and replace on the post content as well as the column that holds the URL on the files table. An easy "hack" to do this would be to perform the search and replace not on the live database, but on the SQL backup file while you move from one host to another, that way in one single operation you can replace everything that needs to be changed, including all third-party extensions and user-inserted links.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants