Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

Agility6
Copy link
Contributor

@Agility6 Agility6 commented Oct 2, 2024

We highly recommend you read the contributor's documentation before starting the review process especially since this is your first contribution to this project.

It was updated on 2024/5/27

What type of PR is this?

feat: #529

Copy link

sonarcloud bot commented Oct 3, 2024

Copy link
Owner

@LinuxSuRen LinuxSuRen left a 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.

image

Please feel free to use the below server if you don't have a good server that supports file upload.

https://github.com/devops-ws/learn-springboot


fileLists.value.push(fileData) // 将文件信息推入fileList

localStorage.setItem('fileLists', JSON.stringify(fileLists.value)) // 存入localStorage
Copy link
Owner

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,
Copy link
Owner

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>
Copy link
Owner

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)
Copy link
Owner

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.

func (e RequestBody) Bytes() (data []byte) {

The decoded content might have many invisible characters. See also

image

@LinuxSuRen LinuxSuRen added the enhancement New feature or request label Oct 3, 2024
@LinuxSuRen
Copy link
Owner

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.

@LinuxSuRen LinuxSuRen closed this Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants