Giter Site home page Giter Site logo

golang-http-file-upload-download's Introduction

golang-http-file-upload-download

A simple example of an HTTP upload and download in Go

Start with

go run main.go

golang-http-file-upload-download's People

Contributors

manisharma avatar mark-kubacki avatar omer-akbas avatar zupzup avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

golang-http-file-upload-download's Issues

check return value of `File.Close()`

It's admittedly a common mistake to forget it, File.Close() can and sometimes does return an error, too, which needs to be handled. (Close() is idempotent, you can call it multiple times.)

As next step you will need to check if a file has been created (despite the error), and if so then remove it.

(Or more elegantly, create with Linux' O_TMPFILE. See my caddy.upload.)

Fix maxUploadSize in article

In article, it is mentioned that const maxUploadSize = 2 * 1024 // 2 MB. But actually right value for 2MB is 2 * 1024 * 1024

Also minor typo: there are two variables filetype and fileType

You know, there are people like me who copy/paste code without reading whole article and directly deploy to prod without testing :)

Get CANT_WRITE_FILE error when I upload a file using Postman

Hi.

I have the same issue on the Postman. At first, the problem occurred because of uploadFile key then it has occurred because of the first CANT_WRITE_FILE statement:

defer newFile.Close()
		if _, err := newFile.Write(fileBytes); err != nil || newFile.Close() != nil {
			renderError(w, "CANT_WRITE_FILE2", http.StatusInternalServerError)
			return
		}

Any suggestion?

Hello

最近一直在找 https-server 类型的上传下载服务器
最近不是 golang 比较火吗?
所以,有兴趣 再修个轮子吗?
大致流程:
server:监听并运行http服务

  • Markdown:自动修改文件名 把特殊字符修改为下划线
  • Markdown 自动填充字段,首尾填充
  • 图片:接收图片并按照时间戳重命名,返回JSON数据

clinet:

  • 向server 发送图片和 markdown文件
  • 接收JSON数据并转达 应用

当然有推荐的欢迎指出,谢谢,❤️

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.