-
Notifications
You must be signed in to change notification settings - Fork 51
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
feat: support to upload file from file manger #542
Conversation
Quality Gate passedIssues Measures |
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.
This is a great idea that put small files into the localStorage. We could have this feature. But it's good to have a size limit, and please feel free to add a server-side to receive those files in a new PR.
By the way, I found some errors when I tried this feature.
Please feel free to use the below server if you don't have a good server that supports file upload.
|
||
fileLists.value.push(fileData) // 将文件信息推入fileList | ||
|
||
localStorage.setItem('fileLists', JSON.stringify(fileLists.value)) // 存入localStorage |
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.
I prefer to move it into console/atest-ui/src/views/cache.ts
, so we can avoid using localStorage
directly.
And please write the comment with English.
const fileData = { | ||
name: file.name, | ||
type: file.type, | ||
size: file.size, |
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.
I suggest giving it a file size limit. For example: 10k
.
@@ -1020,9 +1052,23 @@ Magic.Keys(() => { | |||
<el-radio :label="4">x-www-form-urlencoded</el-radio> | |||
<el-radio :label="5">JSON</el-radio> | |||
<el-radio :label="6">EmbedFile</el-radio> | |||
<el-radio-button :label="7">UploadFile</el-radio-button> |
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.
I prefer to use the same element el-radio
.
const file = fileLists.value.find((e) => e.value === items) | ||
if (file) { | ||
const content = file.content.split(',')[1] | ||
testCaseWithSuite.value.data.request.body = atob(content) |
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.
You can keep it as the base64 encoded content. The below function could decode it on the server side.
api-testing/pkg/testing/case.go
Line 186 in 3a9bde8
func (e RequestBody) Bytes() (data []byte) { |
The decoded content might have many invisible characters. See also
I will close this PR due to the lack of response for a long time. Please feel free to reopen it if you have free time to continue. |
What type of PR is this?
feat: #529