https://github.com/milwad-dev/filei
A golang file uploader package.
https://github.com/milwad-dev/filei
file file-uploader filei go go-file go-library go-package golang uploader
Last synced: over 1 year ago
JSON representation
A golang file uploader package.
- Host: GitHub
- URL: https://github.com/milwad-dev/filei
- Owner: milwad-dev
- License: mit
- Created: 2024-08-07T06:31:32.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-01T15:20:32.000Z (over 1 year ago)
- Last Synced: 2025-03-18T19:54:19.836Z (over 1 year ago)
- Topics: file, file-uploader, filei, go, go-file, go-library, go-package, golang, uploader
- Language: Go
- Homepage:
- Size: 41 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# FileI
The `FileI` is a lightweight and easy-to-use package for handling file operations in Go (Golang). It simplifies common file-related tasks such as uploading, deleting, and managing files, allowing developers to handle file I/O operations with minimal effort. Whether you're building an API, managing assets, or simply need a streamlined way to work with files in Go, FileI provides intuitive methods that integrate seamlessly into your project.
[](https://pkg.go.dev/github.com/milwad-dev/filei)
[](https://github.com/milwad-dev/filei/actions/workflows/tests.yml)
Key Features:
- File Upload: Easily upload files with minimal configuration.
- File Deletion: Remove files from your system with a single function call.
- Error Handling: Provides built-in error handling for common file operations.
- Cross-platform Support: Works across different operating systems.
Perfect for developers who need to manage file operations quickly and efficiently in their Go projects.
## Installation
For install the `FileI` on your project, you can run below command on terminal:
```shell
go get -u github.com/milwad-dev/filei
```
## Usage
- [UploadFile](#upload-file)
- [GetFile](#get-file)
- [DeleteFile](#delete-file)
- [CreateFile](#create-file)
- [Exists](#exists)
- [CleanDirectory](#clean-directory)
- [DeleteDirectory](#delete-directory)
- [MoveFile](#move-file)
- [Files](#files)
- [Size](#size)
- [Chmod](#chmod)
- [Prepend](#prepend)
- [Append](#append)
If you want to upload a file to a path you can use `UploadFile` function:
```go
file, _ := os.Create("testdata/new-text.txt")
err := UploadFile(file, "destPath")
if err != nil {
// ...
}
```
If you want to retrieve a file from the specified path, you can use `GetFile` function:
```go
file, err := GetFile("file path")
if err != nil {
// ...
}
```
If you want to delete a file, you can use `DeleteFile` function:
```go
err := DeleteFile("file path")
if err != nil {
// ...
}
```
If you want to create a file with specific extension and contains a data, you can use `CreateFile` function:
```go
data := []byte("milwad")
err := CreateFile("file path", data)
if err != nil {
// ...
}
```
If you want to ensure that a file exists, you can use `Exists` function:
```go
isExists := Exists("file path") // Bool
```
If you want to clean a directory (remove all files in a directory), you can use `CleanDirectory` function:
```go
CleanDirectory("directory path") // Bool
```
If you want to delete a directory, you can use `DeleteDirectory` function:
```go
err := DeleteDirectory(directory)
```
If you want to move a directory to another path, you can use `MoveDirectory` function:
```go
err := MoveFile(sourcePath, destPath)
```
If you want to get all files of a directory, you can use `Files` function:
```go
files, err := Files(directory)
```
If you want to get a size of a file, you can use `Size` function:
```go
size, err := Size(filePath)
```
If you want to give permission to a file, you can use `Chmod` function:
```go
err := Chmod(filePath, 0700)
```
If you want to write to the beginning of a file, you can use `Prepend` function:
```go
err := Prepend(filePath, data)
```
If you want to write to the end of a file, you can use `Append` function:
```go
err := Append(filePath, data)
```
## License
* This package is created and modified by Milwad Khosravi for Laravel upper more than 9 and has been released under the MIT License.
## Contributing
This project exists thanks to all the people who contribute. [CONTRIBUTING](https://github.com/milwad-dev/filei/graphs/contributors)
## Security
If you've found a bug regarding security please mail [milwad.dev@gmail.com](mailto:milwad.dev@gmail.com) instead of using the issue tracker.
## Donate
If this package is helpful for you, you can buy a coffee for me :) ❤️
- Iraninan Gateway: https://daramet.com/milwad_khosravi
- Paypal Gateway: SOON
- MetaMask Address: `0xf208a562c5a93DEf8450b656c3dbc1d0a53BDE58`