laosb / ghos3

A modernized AWS S3 storage adapter for Ghost.
Other
34 stars 12 forks source link

Importing zip file fails because of a hidden implementation detail #18

Open muratcorlu opened 7 months ago

muratcorlu commented 7 months ago

I tried to import images of a website by making them zip file and import with Ghost admin's import section. But this request failed with the error below:

Cannot read properties of undefined (reading 'split'): An unexpected error occurred, please try again.
  File "/var/lib/ghost/versions/5.82.1/node_modules/@tryghost/mw-error-handler/lib/mw-error-handler.js", line 102, col 19, in module.exports.prepareError
    err = new errors.InternalServerError({
  File "/var/lib/ghost/versions/5.82.1/core/server/data/importer/handlers/image.js", line 18, col 68, in Object.loadFile
    const imageFolderRegexes = _.map(store.staticFileURLPrefix.split('/'), function (dir) {
  File "/var/lib/ghost/versions/5.82.1/core/server/data/importer/import-manager.js", line 318, col 44, in ImportManager.processZip
    const data = await handler.loadFile(files, baseDir);
  File "/var/lib/ghost/versions/5.82.1/core/server/data/importer/import-manager.js", line 491, col 26, in ImportManager.importFromFile
    importData = await this.loadFile(file);
  File "/var/lib/ghost/versions/5.82.1/node_modules/@tryghost/api-framework/lib/pipeline.js", line 259, col 34, in getResponse
    const response = await STAGES.query(apiUtils, apiConfig, apiImpl, frame);
  File "/var/lib/ghost/versions/5.82.1/node_modules/@tryghost/api-framework/lib/pipeline.js", line 264, col 30, in wrapper
    const response = await getResponse();
  File "/var/lib/ghost/versions/5.82.1/node_modules/@tryghost/api-framework/lib/http.js", line 64, col 28, in Http
    const result = await apiImpl(frame);

Apparently it expects a staticFileURLPrefix property of storage adapter, which is not documented in Ghost docs at all.

This is reported with an issue here: https://github.com/TryGhost/Ghost/issues/16530 But apparently it's ignored. I asked this in Ghost Forum as well: https://forum.ghost.org/t/custom-storage-adapter-documentation-is-incomplete/46499

I quickly tried to add this property by setting it to pathPrefix but it didn't work. If I'll have more time, I'll check more deeply. But I wanted to open this issue to make this visible anyway.