downloader

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Index

Constants

This section is empty.

Variables

View Source
var File = router.Handler(func(c router.Context) {
	filename := c.Param("filename")
	filePath := path.Join(config2.Upload.Path, config2.Upload.File.Path, filename)
	if isExistFile := fs.PathExists(filePath); isExistFile == false {

		http.NotFound(c.Writer(), c.Request())
		return
	}

	c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=%v", filename))

	http.ServeFile(c.Writer(), c.Request(), filePath)
})
View Source
var Image = router.Handler(func(c router.Context) {
	filename := c.Param("filename")
	originImagePath := path.Join(config2.Upload.Path, config2.Upload.Image.Path, filename)
	if fs.PathExists(originImagePath) == false {

		http.NotFound(c.Writer(), c.Request())
		return
	}
	c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=%v", filename))
	http.ServeFile(c.Writer(), c.Request(), originImagePath)
})
View Source
var Thumbnail = router.Handler(func(c router.Context) {
	filename := c.Param("filename")
	Config := config2.Upload
	originImagePath := path.Join(Config.Path, Config.Image.Path, filename)
	thumbnailImagePath := path.Join(Config.Path, Config.Image.Thumbnail.Path, filename)
	if fs.PathExists(thumbnailImagePath) == false {

		if fs.PathExists(originImagePath) == true {
			http.ServeFile(c.Writer(), c.Request(), originImagePath)
			return
		}

		http.NotFound(c.Writer(), c.Request())
		return
	}
	c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=%v", filename))
	http.ServeFile(c.Writer(), c.Request(), thumbnailImagePath)
})

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL