-
Notifications
You must be signed in to change notification settings - Fork 1
fix(rpc): action with file #307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: fix/rpc/action-response
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,7 @@ | ||
| require 'base64' | ||
| require 'cgi' | ||
| require 'json' | ||
| require 'stringio' | ||
|
|
||
| module ForestAdminDatasourceRpc | ||
| class Collection < ForestAdminDatasourceToolkit::Collection | ||
|
|
@@ -127,7 +130,12 @@ def execute(caller, name, data, filter = nil) | |
| "Forwarding '#{@name}' action #{name} call to the Rpc agent on #{url}." | ||
| ) | ||
|
|
||
| @client.call_rpc(url, caller: caller, method: :post, payload: params, symbolize_keys: true) | ||
| response = @client.call_rpc(url, caller: caller, method: :post, payload: params, | ||
| symbolize_keys: true, with_response: true) | ||
|
|
||
| return build_file_result(response) if response.headers['x-forest-action-type'] == 'File' | ||
|
|
||
| response.body | ||
| end | ||
|
|
||
| def get_form(caller, name, data = nil, filter = nil, metas = nil) | ||
|
|
@@ -176,5 +184,20 @@ def encode_form_data(data) | |
| end | ||
| end | ||
| end | ||
|
|
||
| def build_file_result(response) | ||
| response_headers_header = response.headers['x-forest-action-response-headers'] | ||
| file_name_header = response.headers['x-forest-action-file-name'] | ||
|
|
||
| result = { | ||
| type: 'File', | ||
| mime_type: response.headers['content-type'], | ||
| name: CGI.unescape(file_name_header.to_s), | ||
| stream: response.body.to_s | ||
| } | ||
| result[:response_headers] = JSON.parse(response_headers_header) if response_headers_header | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟢 Low When - result[:response_headers] = JSON.parse(response_headers_header) if response_headers_header🚀 Reply "fix it for me" or copy this AI Prompt for your agent: |
||
|
|
||
| result | ||
| end | ||
| end | ||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function with many parameters (count = 7): call_rpc [qlty:function-parameters]