Coder Social home page Coder Social logo

gin-uploader's Introduction

go文件上传模块

完整实例

  • 文件上传
  • 限制上传文件的后缀名
  • 限制上传文件的大小
  • Hash去重,防止重复上传
  • 图片自动生成缩略图
  • 全由配置

如何运行

go get -v github.com/axetroy/gin-uploader
package main

import (
	"github.com/gin-gonic/gin"
	"github.com/axetroy/gin-uploader"
)

func main() {
	Router := gin.Default()

	uploader.Resolve(Router, uploader.TConfig{
		Path: "upload",
		UrlPrefix: "/api/v1",
		File: uploader.FileConfig{
			Path:      "files",
			MaxSize:   10485760,
			AllowType: []string{},
		},
		Image: uploader.ImageConfig{
			Path:    "images",
			MaxSize: 10485760,
			Thumbnail: uploader.ThumbnailConfig{
				Path:      "thumbnail",
				MaxWidth:  300,
				MaxHeight: 300,
			},
		},
	})

	if err := Router.Run("localhost:9090"); err != nil {
		panic(err)
		return
	}

})

API

# 上传相关
[POST]  /upload/image                           # 图片上传
[POST]  /upload/file                            # 其他文件上传
[GET]   /upload/example                         # 上传demo,仅在开发模式下
# 下载相关
[GET]   /download/image/origin/:filename        # 获取上传的原始图片
[GET]   /download/image/thumbnail/:filename     # 获取上传的缩略图片
[GET]   /download/file/download/:filename       # 下载文件
[GET]   /download/file/raw/:filename            # 获取文件

License

FOSSA Status

gin-uploader's People

Contributors

axetroy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.