Fs.readFileSync does not work, cannot see any local files for Forge


I am trying to use https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-avatars/#api-rest-api-2-universal-avatar-type-type-owner-entityid-post, to upload an avatar for issue types, in order to do so, I need a avatar logo to be passed in the post body, to do so I have tried fs.readFileSync, but the files with this method, produces file not found error. Using fs.readdirSync, I can see that no files show up in the current directory.

As an alternative I have done a fetch to get the image from online, the current implementation with this endpoint works for me but it would be better to not depend on a hosted file. Has anybody encountered this using forge?

If I understand the question right you’re trying to access a file you’ve uploaded to your Forge app and now trying to add it to a POST request.

Since we use serverless functions the filesystem does not persist on executions. You will have to upload and POST at the same request.