使用n8n自动化AWS S3操作:存储桶、文件夹和文件
高级
这是一个Content Creation、Multimodal AI领域的自动化工作流,包含 20 个节点。主要使用 Set、AwsS3、ManualTrigger、Agent、OpenAi 等节点。 将AI生成图像存储到AWS S3:OpenAI图像创建与云存储
前置要求
- •AWS Access Key 和 Secret
- •OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "hA8TizePEKZNGeee",
"meta": {
"instanceId": "4a2e6764ba7a6bc9890d9225f4b21d570ce88fc9bd57549c89057fcee58fed0f",
"templateCredsSetupCompleted": true
},
"name": "Automating AWS S3 Operations with n8n: Buckets, Folders, and Files",
"tags": [],
"nodes": [
{
"id": "8839c349-fde5-4fef-9b73-e337e47c0deb",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
1424,
240
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "PPSwAKeLQYgAPobT",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "94dd22ea-6cf3-4c7f-9b20-a9b11680ec1d",
"name": "Generate an image",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
1728,
16
],
"parameters": {
"prompt": "={{ $json.output }}",
"options": {},
"resource": "image"
},
"credentials": {
"openAiApi": {
"id": "PPSwAKeLQYgAPobT",
"name": "OpenAi account"
}
},
"typeVersion": 1.8
},
{
"id": "7108a3aa-a2d5-4167-9c16-5201c0fe11d1",
"name": "上传文件",
"type": "n8n-nodes-base.awsS3",
"position": [
2224,
16
],
"parameters": {
"fileName": "={{ $('Edit Fields').item.json.folder_name }}/image_{{ $now.format('yyyy-MM-dd') }}.{{ $json.fileExtension }}",
"operation": "upload",
"bucketName": "=bucket{{ $workflow.id }}",
"additionalFields": {}
},
"credentials": {
"aws": {
"id": "IZYsJuHhfVJ3PIrC",
"name": "AWS account"
}
},
"typeVersion": 2
},
{
"id": "548ec1cf-53dc-4df0-b2f4-9c17d795af4c",
"name": "Prompt Generation Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
1328,
16
],
"parameters": {
"text": "=You're prompt generator agent, you will create prompt for the open-ai image generation model with a random topic among:\n- Education\n- Science \n- Sport\n- Economy\n- Health\nOutput the prompt only, nothing else",
"options": {},
"promptType": "define"
},
"typeVersion": 2.1
},
{
"id": "0c16a07e-9892-442c-840a-abc9201c8b85",
"name": "当点击\"执行工作流\"时",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-320,
16
],
"parameters": {},
"typeVersion": 1
},
{
"id": "a1cabec4-957e-4954-aae9-ea54103fc379",
"name": "Create AWS S3 Bucket",
"type": "n8n-nodes-base.awsS3",
"onError": "continueRegularOutput",
"position": [
736,
16
],
"parameters": {
"name": "=bucket{{ $workflow.id }}",
"resource": "bucket",
"additionalFields": {
"region": "={{ $('Edit Fields').item.json.aws_region }}"
}
},
"credentials": {
"aws": {
"id": "IZYsJuHhfVJ3PIrC",
"name": "AWS account"
}
},
"typeVersion": 2
},
{
"id": "96a3f0bc-468a-42e2-b07f-0d57636c9b5a",
"name": "Create a folder",
"type": "n8n-nodes-base.awsS3",
"position": [
1104,
16
],
"parameters": {
"resource": "folder",
"bucketName": "=bucket{{ $workflow.id }}",
"folderName": "={{ $('Edit Fields').item.json.folder_name }}",
"additionalFields": {}
},
"credentials": {
"aws": {
"id": "IZYsJuHhfVJ3PIrC",
"name": "AWS account"
}
},
"typeVersion": 2
},
{
"id": "7e6da7e5-721f-4979-9101-c477d6a9b9cf",
"name": "编辑字段",
"type": "n8n-nodes-base.set",
"position": [
96,
16
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "af3e6c69-fbfe-49f4-9c29-3a68a821c5a6",
"name": "aws_region",
"type": "string",
"value": "ap-southeast-1"
},
{
"id": "1a693ae0-2ba0-4b1b-a00a-4399a8d3ab57",
"name": "folder_name",
"type": "string",
"value": "my_s3_folder"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "a962b9e3-a7f0-4fa9-9d79-3726d5f4d2b9",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1264,
-480
],
"parameters": {
"width": 816,
"height": 1280,
"content": "# Automating AWS S3 Operations with n8n: Buckets, Folders, and Files\n\nThis tutorial walks you through setting up an automated workflow that **generates AI-powered images** from prompts and securely stores them in **AWS S3**. It leverages the new **AI Tool Node** and OpenAI models for prompt-to-image generation. \n\n## **Who’s it for**\nThis workflow is ideal for:\n- **Designers & marketers** who need quick, on-demand AI-generated visuals. \n- **Developers & automation builders** exploring **AI-driven workflows** integrated with cloud storage. \n- **Educators or trainers** creating tutorials or exercises on AI image generation. \n- **Businesses** looking to automate **image content pipelines** with AWS S3 storage. \n\n## **How it works / What it does**\n1. **Trigger**: The workflow starts manually when you click **“Execute Workflow”**. \n2. **Edit Fields**: You can provide input fields such as image description, resolution, or naming convention. \n3. **Create AWS S3 Bucket**: Automatically creates a new **S3 bucket** if it doesn’t exist. \n4. **Create a Folder**: Inside the bucket, a folder is created to organize generated images. \n5. **Prompt Generation Agent**: An AI agent generates or refines the image prompt using the **OpenAI Chat Model**. \n6. **Generate an Image**: The refined prompt is used to generate an image using AI. \n7. **Upload File to S3**: The generated image is uploaded to the AWS S3 bucket for secure storage. \n\nThis workflow showcases how to combine **AI + Cloud Storage** seamlessly in an automated pipeline. \n\n## **How to set up**\n1. **Import the workflow** into **n8n**. \n2. Configure the following credentials: \n - **AWS S3** (Access Key, Secret Key, Region). \n - **OpenAI API Key** (for Chat + Image models). \n3. Update the **Edit Fields node** with your preferred input fields (e.g., image size, description). \n4. Execute the workflow and test by entering a sample image prompt (e.g., *“Futuristic city skyline in watercolor style”*). \n5. Check your AWS S3 bucket to verify the uploaded image. \n\n## **Requirements**\n- **n8n** (latest version with AI Tool Node support). \n- **AWS account** with S3 permissions to create buckets and upload files. \n- **OpenAI API key** (for prompt refinement and image generation). \n- Basic familiarity with **AWS S3 structure** (buckets, folders, objects). \n\n## **How to customize the workflow**\n- **Custom Buckets**: Replace the auto-create step with an existing S3 bucket. \n- **Image Variations**: Generate multiple image variations per prompt by looping the image generation step. \n- **File Naming**: Adjust file naming conventions (e.g., timestamp, user input). \n- **Metadata**: Add metadata such as tags, categories, or owner info when uploading to S3. \n- **Alternative Storage**: Swap AWS S3 with **Google Cloud Storage, Azure Blob, or Dropbox**. \n- **Trigger Options**: Replace manual trigger with **Webhook, Form Submission, or Scheduler** for automation. \n\n✅ This workflow is a **hands-on example** of how to combine **AI prompt engineering, image generation, and cloud storage automation** into a single streamlined process. "
},
"typeVersion": 1
},
{
"id": "9bbf079c-2987-484a-886c-9b0884e5049c",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-368,
-272
],
"parameters": {
"color": 4,
"width": 448,
"height": 192,
"content": "## Step 1: Trigger Workflow\n- The workflow begins when you **click “Execute Workflow”** in n8n. \n- This is a manual trigger, giving you control over when to generate images. \n👉 You can later replace this with a **Webhook** or **Scheduler** if you want automation."
},
"typeVersion": 1
},
{
"id": "e181e6ad-0c22-414d-aefb-6fdc6811db21",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-144,
208
],
"parameters": {
"color": 4,
"width": 448,
"height": 272,
"content": "## Step 2: Edit Fields\n- This node allows you to **manually provide input fields** for the workflow. \n- Typical inputs include: \n - **Image Description** (e.g., *“A futuristic city skyline in watercolor style”*) \n - **Image Size** (e.g., 512x512, 1024x1024) \n - **Folder Name** (to organize images in S3) \n\n👉 Customize these fields to fit your use case (e.g., campaign name, project ID). \n"
},
"typeVersion": 1
},
{
"id": "2263ecde-5632-4a67-ab9b-bad883b0215e",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
320,
-288
],
"parameters": {
"color": 4,
"width": 432,
"height": 224,
"content": "## Step 3: Create AWS S3 Bucket\n- The workflow will create a new **AWS S3 bucket** to store your images. \n- If the bucket already exists, it will skip this step. \n- Recommended format: `ai-images-demo-[yourname]`. \n\n👉 Make sure your AWS credentials in n8n have **permission to create buckets**. "
},
"typeVersion": 1
},
{
"id": "9a1b2396-a262-4540-85d7-11576ce70d0f",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
720,
288
],
"parameters": {
"color": 4,
"width": 432,
"content": "## Step 4: Create a Folder\n- Inside your S3 bucket, a **folder** (sometimes called a “prefix”) is created. \n- This helps keep images organized (e.g., by project, user, or campaign). \n- Example: `ai-images/marketing/` \n\n👉 You can also dynamically name folders using values from the **Edit Fields** step. "
},
"typeVersion": 1
},
{
"id": "41197544-3daa-4d41-9152-8887f59d4894",
"name": "便利贴5",
"type": "n8n-nodes-base.stickyNote",
"position": [
992,
-288
],
"parameters": {
"color": 4,
"width": 544,
"height": 208,
"content": "## Step 5: Prompt Generation Agent\n- This node uses the **OpenAI Chat Model** to **refine your prompt** before generating the image. \n- Example: If you enter *“dog in a park”*, the agent might expand it to: \n *“A realistic illustration of a golden retriever running in a lush green park, morning sunlight, 4K resolution.”* \n\n👉 This ensures better and more consistent image quality. "
},
"typeVersion": 1
},
{
"id": "f6cc0eca-f4e1-41b0-ab62-fda3bedc074c",
"name": "便签 6",
"type": "n8n-nodes-base.stickyNote",
"position": [
1424,
224
],
"parameters": {
"color": 4,
"width": 544,
"height": 240,
"content": "## Step 6: Generate an Image\n- Using the refined prompt, the **OpenAI Image Generation model** creates an image. \n- You can define: \n - Resolution (512px, 1024px, etc.) \n - Style (realistic, watercolor, anime, etc.) \n- Output will be a **PNG or JPEG file**. \n\n👉 You can generate multiple variations by looping this step. "
},
"typeVersion": 1
},
{
"id": "da9e8e07-bb47-4270-b0af-16e2e3dabd29",
"name": "便签 7",
"type": "n8n-nodes-base.stickyNote",
"position": [
1808,
-272
],
"parameters": {
"color": 4,
"width": 560,
"height": 208,
"content": "## Step 7: Upload File to AWS S3\n- The generated image is uploaded into your S3 bucket and folder. \n- The file is given a unique name (e.g., `image_2025-08-17_12-30.png`). \n- Once uploaded, you can: \n - Share the S3 file link \n - Use it in your applications or websites \n\n👉 Make sure your bucket allows the right access policy (public or private). "
},
"typeVersion": 1
},
{
"id": "967a41d5-1d28-4ff8-93f5-aff3b6cdeb38",
"name": "Delete a folder",
"type": "n8n-nodes-base.awsS3",
"disabled": true,
"position": [
752,
-464
],
"parameters": {
"resource": "folder",
"folderKey": "={{ $('Edit Fields').item.json.folder_name }}",
"operation": "delete",
"bucketName": "=bucket{{ $workflow.id }}"
},
"credentials": {
"aws": {
"id": "IZYsJuHhfVJ3PIrC",
"name": "AWS account"
}
},
"typeVersion": 2
},
{
"id": "3aa92356-4bf3-4039-b431-ffc9e28deef9",
"name": "Delete uploaded image",
"type": "n8n-nodes-base.awsS3",
"disabled": true,
"position": [
304,
-464
],
"parameters": {
"fileKey": "={{ $('Edit Fields').item.json.folder_name }}/image_{{ $now.format('yyyy-MM-dd') }}.png",
"options": {},
"operation": "delete",
"bucketName": "=bucket{{ $workflow.id }}"
},
"credentials": {
"aws": {
"id": "IZYsJuHhfVJ3PIrC",
"name": "AWS account"
}
},
"typeVersion": 2
},
{
"id": "7ab94a69-9ca2-4ee0-8db9-db2037fe087a",
"name": "便签8",
"type": "n8n-nodes-base.stickyNote",
"position": [
80,
-800
],
"parameters": {
"width": 496,
"height": 288,
"content": "## Step 8: Delete an Object\n- This step lets you **remove a specific file (object) from your S3 bucket**. \n- Typical use cases: \n - Replacing outdated images. \n - Cleaning up test runs. \n- Input required: \n - **Bucket Name** (where the file is stored) \n - **Object Key** (file path, e.g., `ai-images/marketing/image_2025-08-17_12-30.png`) \n\n👉 Be careful: this action is permanent and cannot be undone. \n"
},
"typeVersion": 1
},
{
"id": "74d397eb-4f59-4709-8fd2-650b5a67f0f5",
"name": "便签 9",
"type": "n8n-nodes-base.stickyNote",
"position": [
640,
-816
],
"parameters": {
"width": 496,
"height": 304,
"content": "## Step 9: Delete a Folder\n- This step allows you to **delete an entire folder (prefix) in S3**. \n- It will remove all objects inside that folder. \n- Typical use cases: \n - Clearing old project assets. \n - Cleaning up after workflow tests. \n- Input required: \n - **Bucket Name** \n - **Folder Path** (e.g., `ai-images/marketing/`) \n\n👉 Note: AWS S3 doesn’t have real folders—just prefixes. Deleting a folder means removing **all objects with that prefix**. "
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "903b5b9d-560c-40db-83dc-ac2acd5a3cf3",
"connections": {
"Edit Fields": {
"main": [
[
{
"node": "Create AWS S3 Bucket",
"type": "main",
"index": 0
},
{
"node": "Delete uploaded image",
"type": "main",
"index": 0
}
]
]
},
"Upload a file": {
"main": [
[]
]
},
"Create a folder": {
"main": [
[
{
"node": "Prompt Generation Agent",
"type": "main",
"index": 0
}
]
]
},
"Generate an image": {
"main": [
[
{
"node": "Upload a file",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Prompt Generation Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Create AWS S3 Bucket": {
"main": [
[
{
"node": "Create a folder",
"type": "main",
"index": 0
}
]
]
},
"Delete uploaded image": {
"main": [
[
{
"node": "Delete a folder",
"type": "main",
"index": 0
}
]
]
},
"Prompt Generation Agent": {
"main": [
[
{
"node": "Generate an image",
"type": "main",
"index": 0
}
]
]
},
"When clicking ‘Execute workflow’": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
这是一个高级难度的工作流,适用于Content Creation、Multimodal AI等场景。适合高级用户,包含 16+ 个节点的复杂工作流
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
使用AI Tool Node和GPT-4、DALL-E的多智能体图书创作工作流
使用GPT-4.1-mini、DALL-E、Google Drive和AWS S3创建AI生成图书
Set
Aws S3
Markdown
+9
25 节点Trung Tran
Content Creation
初学者教程:使用 n8n 管理 Azure 存储账户容器和 Blob
使用 DALL-E 和 Azure Blob 存储生成并存储 AI 图像
Set
Azure Storage
Manual Trigger
+4
21 节点Trung Tran
Content Creation
初学者教程:使用n8n管理Google Cloud Storage存储桶和对象
使用GPT-4 Mini AI图像生成管理Google Cloud Storage
Set
Manual Trigger
Agent
+5
18 节点Trung Tran
File Management
AI驱动的邮件分诊与自动回复系统,集成OpenAI代理和Gmail
AI驱动的邮件分诊与自动回复系统,集成OpenAI代理和Gmail
If
Set
Gmail
+20
68 节点Abdullahi Ahmed
Content Creation
使用 OpenAI、ElevenLabs 和 Fal.ai 自动化病毒式内容创作,适用于视频、播客和 ASMR
使用 OpenAI、ElevenLabs 和 Fal.ai 自动化病毒式内容创作,适用于视频、播客和 ASMR
Set
Code
Wait
+16
97 节点Adam Crafts
Content Creation
基于 YouTube 视频的自主博客发布
使用 ChatGPT、Sheets、Apify、Pexels 和 WordPress 从 YouTube 视频自主发布博客
If
Set
Code
+18
80 节点Oriol Seguí
Content Creation
工作流信息
难度等级
高级
节点数量20
分类2
节点类型7
作者
Trung Tran
@trungtranEmpowering small and medium businesses with smart automation and practical AI, no big tech team required.
外部链接
在 n8n.io 上查看 →
分享此工作流