Tek Dosya Yükleme

const maxSize = 8 * iris.MB

func main() {
    app := iris.Default()

    app.Post("/upload", func(ctx iris.Context) {
        // İstek gövde boyut sınırını ayarlar, bu dosya yükleme boyutunu sınırlandırır (varsayılan 32 MiB)
        ctx.SetMaxRequestBodySize(maxSize)
        // Veya
        // app.Use(iris.LimitRequestBodySize(maxSize))
        // Veya
        // iris.WithPostMaxMemory(maxSize)

        // Dosyayı oku
        file, fileHeader, err:= ctx.FormFile("file")
        if err != nil {
            ctx.StopWithError(iris.StatusBadRequest, err)
            return
        }

        // Yüklenen dosyayı belirtilen dizine kaydet
        dest := filepath.Join("./uploads", fileHeader.Filename)
        ctx.SaveFormFile(fileHeader, dest)

        ctx.Writef("Dosya: %s yüklendi!", fileHeader.Filename)
    })

    app.Listen(":8080")
}

Dosya yükleme testi

curl -X POST http://localhost:8080/upload \
  -F "file=@/Users/kataras/test.zip" \
  -H "Content-Type: multipart/form-data"

Birden Fazla Dosya Yükleme

func main() {
    app := iris.Default()
    app.Post("/upload", func(ctx iris.Context) {
        // Birden fazla dosyayı oku
        files, n, err := ctx.UploadFormFiles("./uploads")
        if err != nil {
            ctx.StopWithStatus(iris.StatusInternalServerError)
            return
        }

        ctx.Writef("%d dosya yüklendi, toplam boyut: %d!", len(files), n)
    })

    app.Listen(":8080", iris.WithPostMaxMemory(8 * iris.MB))
}

Birden fazla dosya yükleme testi

curl -X POST http://localhost:8080/upload \
  -F "upload[]=@/Users/kataras/test1.zip" \
  -F "upload[]=@/Users/kataras/test2.zip" \
  -H "Content-Type: multipart/form-data"