Hi,
I tried to create action with below code.
function main(params) {
//var test = async function() {
const adobeIOSdk = require('@adobe/aio-sdk')
//const presignUrl = await files.generatePresignURL('mydir/myfile.txt', { expiryInSeconds: 60 })
const presignUrl = 'test'
//return presignUrl
//}
return {
statusCode: 200,
body: {
payload: presignUrl
}
}
}
but when I invoke got an error saying like below.
An error has occurred: Error: Cannot find module '@adobe/aio-sdk'\nRequire stack:\n- /nodejsAction/runner.js\n- /nodejsAction/src/service.js\n- /nodejsAction/app.js
Thanks
Naveen
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @Aditya82Ram ,
You have to deploy your action under headless application. https://www.adobe.io/project-firefly/docs/overview/firefly_and_runtime/
Thanks
Naveen
Views
Replies
Total Likes
Hi @Naveen_Srinivas,
I am facing a similar issue - trying to access S3 files that requires aws-sdk module.
I am wondering if packages can be used to circumvent the local dependency issue.
I look forward to hearing your take on this. Alternatively please feel free to let me know of any other ideas you may have around this.
Cheers!
Views
Replies
Total Likes
Hi @Aditya82Ram ,
You have to deploy your action under headless application. https://www.adobe.io/project-firefly/docs/overview/firefly_and_runtime/
Thanks
Naveen
Views
Replies
Total Likes
Hi @Naveen_Srinivas,
Thank you for sharing this. I will explore further into this.
Quick question though: is this approach applicable to non-Adobe products as well?
I need to access a file in S3; my JavaScript code requires aws-sdk (instead of aio-sdk, in your case). Does the headless application method you suggested work for any module, or is it specific to only Adobe-related products.
Thanks!
P.S. Please don't mind if I have incorrectly stated something - I am learning JavaScript on the job!
Views
Replies
Total Likes
I guess it will work, first you need to install aws-sdk in your app folder node_modules and in index.js you can utilize.
You can invoke this web-actions using api call.
Views
Replies
Total Likes
Alright. I will try this. Thanks!
Views
Replies
Total Likes
What @Naveen_Srinivas mentioned is our recommendation as well.
Writing your Runtime actions in the Project Firefly structure will help to build and deploy your code automatically, without much effort for adding custom modules.
You only need to add the required modules in package.json, and run npm install.
This applies to non-Adobe modules as well.
Views
Likes
Replies