Closed hwlmatt closed 2 years ago
I have a version of this working in a test zap now.
This is handling all image fields (featured_image
, twitter_image
, and og_image
) and only uploading unique files. It uses the same upload response for fields sharing the same file pointer (Zapier "stash file"). Added this file to /lib/
, and made create_post()
async. The edited create_post()
is on the same gist here.
It basically does the following:
__GHOST__
urlFrom there the create_post()
operates as is.
Happy to PR if it meets the coding standards/requirements, etc.
This is where I started on this. Just handles the feature_image
upload.
Added this file to /lib/
, and made create_post()
async. The edited create_post()
is on the same gist here.
Hey @hwlmatt the PR where we could discuss and see the differences would be much appreciated. Some comments on the approach you've taken:
__GHOSTURL__
existenceThere have not been reports about this issue ever since the initial report. I'll close it out for now and very happy to reopen and let @royalfig to give a hand if there's interest in fixing this bug.
Expected Behavior
Featured Image field uploads the selected image to Ghost
Actual Behavior
The Featured Image field is not uploading an image file passed to it, but rather saving the uri reference pointer (the stashFile like in this example created during a previous step's hydrator (download from external source to zapier). This results in site images being served from Zapier's stashfile url.
Steps to Reproduce
<img src="https://zapier.com/engine/hydrate/00000000/##################.../"...
Possible Cause
Cause
Line 99 of create_post.js{key: 'feature_image', required: false},is missing `type: 'file'Ghost's createPost function is not handling dehydration.So I thinkthis is just passing along that pointer uri as a text string.That uri gets saved on the site's end, and loaded on the frontend as an externally hosted image. But that uri is intended to be passed and dehydrated, not as a permanent uri of a file.
Possible Fix
[ UPDATE: see comment below with links to gists. I have uploads working in a clone of this now.] Handling multiple passed files and only uploading uniques, and getting the string back from Ghost api to pass with the rest of the createPost form.
Optional: Could add a dehydrateFile method to createPost's res if you wish to make the Ghost uploaded image available to future Zap steps. Thought this doesn't seem necessary.
Sorry I couldn't be more help with a PR or something, I'm not where I can setup anything to test, etc.Happy to do a PR if the gists in my later comment look up to standards.Reference docs
This is an example of an upload hydration/dehydration: https://github.com/codebycaleb/zapier-hydration-example/blob/master/creates/uploadFile.js
Zapier's cli docs on hydration/dehydration