TryGhost / Ghost

Independent technology for modern publishing, memberships, subscriptions and newsletters.
https://ghost.org
MIT License
47.38k stars 10.34k forks source link

image URL is invalid when hosted on windows #7943

Closed cookiejest closed 7 years ago

cookiejest commented 7 years ago

Issue Summary

Image URLs do not work when hosted on windows.

Steps to Reproduce

I am doing file upload to s3 using 'ghost-s3-storage-adapter'.

The s3 image is stored with a date and at the start like so:

'2017/02/originalimagename.png'

It seems to be adding the date before the image name. This works when using local storage. However when uploading to S3 the image reference is then incorrect. The image reference would be like so:

[https://s3-eu-west-1.amazonaws.com/[SOMES3BUCKET]/2017\02\Coriginalimagename.png]

This is not valid and so the image does not display. The correct URL for something like this would be:

[https://s3-eu-west-1.amazonaws.com/[SOMES3BUCKET]/2017%5C02%5Coriginalimagename.png]

However idealy should not be putting \ into image names. It would be better to use '-'

Any ideas how I could do that? Thanks,

Technical details:

acburdine commented 7 years ago

Hey @cookiejest, sorry to hear you're having trouble!

As you said - it works when using local storage, so this is likely not a problem with Ghost itself. As such, it is most likely a problem with the ghost-s3-storage-adapter here: https://github.com/aorcsik/ghost-s3-storage-adapter. I'd suggest opening up an issue there 😄

If it turns out that this is an issue with Ghost itself, then this issue can be reopened. Thanks!

cookiejest commented 7 years ago

ok, to help me figure this out, does ghost preappend the '2017/02' or is it that module?

Because if it is ghost there should be some option to change the format

cookiejest commented 7 years ago

becuase it seems to be that ghost passes the image name

acburdine commented 7 years ago

@cookiejest Ghost does pass the image name (with the date prepended) - because by default it stores it locally in the filesystem (which needs the right slashes prepended).

Ghost has a way to override the directory that is passed though: see here. If the ghost-s3-storage-adapter overrides that function, then it can better normalize the slashes.