Want to put a file itself as an argument of code execution.
Self Checks
- [X] I have searched for existing issues search for existing issues, including closed ones.
- [X] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
- [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
- [X] Please do not modify this template :) and fill in all the required fields.
1. Is this request related to a challenge you're experiencing? Tell me about your story.
I'd like to unzip a file. So try to put a file "itself" as a arg but I can't.
2. Additional context or comments
If there is another way to unzip a file, it may help me.
3. Can you help us with this feature?
- [ ] I am interested in contributing to this feature.
Dify allows you to handle files by using "file variables" in its workflow applications. However, directly passing a file itself as an argument for code execution, such as unzipping, isn't directly supported through a built-in feature for unzipping files. Instead, you can upload files as variables and process them using available tools like document extractors for text extraction.
For unzipping files, you might need to implement a custom solution or use an external service or library that can handle file decompression. Unfortunately, there isn't specific documentation or built-in support for unzipping files within Dify that I could find. You might consider using a script or a third-party service that can be integrated into your workflow to handle this task.
To continue talking to Dosu, mention @dosu.
Well, I think you will need a https://docs.dify.ai/guides/workflow/node/http-request node to sent it out to a custom endpoint to extract there for now. Why do you want to unzip a file here?
@crazywoola The reason is that I am planning to create a workflow to process emails, along with attachments.
So I thought that if binaries like Excel and Word can be processed, it would be more consistent to be able to process Zip files as well.
However, I had a feeling that there was a reason for this as dosubot mentioned. With that in mind, I think your idea is brilliant.👍
I would like to FR if anyone else needs it.
@mihit Facing the same problem. Have you found the path of the uploaded file? Without the path, how to send the file to the outside services through http request? I tried to find the file path, but nothing. The fields of the file are as below:
{
"contact_file": {
"dify_model_identity": "__dify__file__",
"id": null,
"tenant_id": "8d508036-fa09-4de7-9473-be81cb13ffeb",
"type": "document",
"transfer_method": "local_file",
"remote_url": "",
"related_id": "359a48a9-0379-4826-a5cc-f98634997930",
"filename": "xxx.docx",
"extension": ".docx",
"mime_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"size": 2229042,
"url": "/files/359a48a9-0379-4826-a5cc-f98634997930/file-preview?timestamp=1733727725&nonce=201b855639de363011654adbfc5a3e00&sign=meEYfwr5JqE9BnuMMXRu3DJLb3Z4qj4Kj45Qyy7xyLk="
},
"sys.files": [],
"sys.user_id": "f91da615-8f71-4092-997d-9d18a820f10d",
"sys.app_id": "6285ccc0-901e-4943-b56b-b19ad0aaacb1",
"sys.workflow_id": "1b8287f2-360e-4ac4-940b-6340b4ed081f",
"sys.workflow_run_id": "fec90373-c5d0-4b1a-b9f5-a5a80a66ceaf"
}
@chilejiang1024 On body section, set mime type as form-data or binary, then you can choose an Array[File] as value.
Same exception here, the only difference is that I create a custom tool with existing workflow, accepting LLM file input, which results into error.
Exception:
Failed to invoke tool: File.__init__() got an unexpected keyword argument 'dify_model_identity'
The custom tool input parameters:
{
"pdf": {
"dify_model_identity": "__dify__file__",
"id": null,
"tenant_id": "0fcd55b1-5b06-4280-a97c-38395151bd52",
"type": "document",
"transfer_method": "local_file",
"remote_url": "",
"related_id": "b06dc7b5-3d1c-4400-bb97-d890cee26a3b",
"filename": "cs101.pdf",
"extension": ".pdf",
"mime_type": "application/pdf",
"size": 216899,
"url": "/files/b06dc7b5-3d1c-4400-bb97-d890cee26a3b/file-preview?timestamp=1735551458&nonce=f10c04fc2226a5464cc84696507c5c1c&sign=rPYD327G1Y3kRkRDCMyAaVAeucSxxqNUZBw8J5qw-TQ="
}
}
The issue could be resolved by changing the File init method at api/core/file/models.py.
You could add parameters like *args, **kwargs or dify_model_identity:Any=None.
I'm also having trouble handling Array[file].
I want to implement various subsequent processes using the image URLs output by the ComfyUI tool, such as converting them to Base64 or sending them to Notion, but I can't.
Is there a way to treat Array[file] as a simple String?

Hi, @mihit. I'm Dosu, and I'm helping the Dify team manage their backlog. I'm marking this issue as stale.
Issue Summary:
- You requested a feature to use files as arguments for code execution, specifically for unzipping files.
- Dify supports file handling through "file variables," but not direct unzipping; custom solutions were suggested.
- Crazywoola proposed using an HTTP request node for file extraction, which you found promising.
- Other users shared related challenges and solutions, like handling file paths and modifying methods to resolve exceptions.
Next Steps:
- Please let us know if this issue is still relevant to the latest version of Dify by commenting here.
- If there is no further activity, this issue will be automatically closed in 15 days.
Thank you for your understanding and contribution!