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

refactor(context): Added an optional permission parameter to the SaveUploadedFile method (#4068) #4085

Closed
wants to merge 5 commits into from

Conversation

haesuo566
Copy link
Contributor

@haesuo566 haesuo566 commented Nov 3, 2024

The SaveUploadedFile method previously set folder permissions to 0o750 by default when creating directories. A third parameter, ...fs.FileMode, has been added to allow customizable permissions. This update enables users to optionally set folder permissions when creating directories and files with the SaveUploadedFile method.

func SaveFile(ctx *gin.Context) error {
	file, err := ctx.FormFile("file")
	if err != nil {
		return err
	}

	var perm fs.FileMode = 0o755
	return ctx.SaveUploadedFile(file, "/asset/file", perm)
}

@appleboy appleboy added this to the v1.11 milestone Nov 6, 2024
@appleboy
Copy link
Member

appleboy commented Nov 6, 2024

@haesuo566 test error.

@haesuo566
Copy link
Contributor Author

@appleboy I’ve committed the fix for the issue where the permissions weren’t being set correctly due to the umask, which was causing the test to fail. Please review it.

@appleboy
Copy link
Member

appleboy commented Nov 7, 2024

@haesuo566 still failed in lint testing.

hso and others added 3 commits November 7, 2024 15:04
Squashed commit:

[75fe2b9] Fixed part where permissions could not be changed due to umask settings

[84b3770] refactor(context): Added a third, optional parameter for permissions to the SaveUploadedFile method. (#4068)
@haesuo566 haesuo566 closed this Nov 7, 2024
@haesuo566 haesuo566 reopened this Nov 7, 2024
@haesuo566 haesuo566 closed this Nov 7, 2024
@haesuo566 haesuo566 deleted the develop branch November 7, 2024 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants