Example #1
0
func (u *UploadController) UploadPart(params martini.Params, res http.ResponseWriter, req *http.Request) (int, string) {
	partNumber, err := strconv.Atoi(params["partNumber"])
	if err != nil {
		panic(err)
	}
	uploadId := params["uploadId"]
	body, err := ioutil.ReadAll(req.Body)
	if err != nil {
		panic(err)
	}

	upload := domain.NewUpload()
	etag := upload.AddPart(partNumber, uploadId, body)

	return 200, etag
}
Example #2
0
func (u *UploadController) InitiateMultipartUpload(req *http.Request, db domain.Database) (int, string) {

	upload := domain.NewUpload()
	upload.GetNewUploadId()
	upload.Filename = u.parseFilename(req)
	upload.Bucket = u.parseBucket(req)
	upload.Key = u.parseKey(req)

	db.CreateUpload(upload)

	result := webservice.InitiateMultipartUploadResult{UploadId: upload.UploadId, Bucket: upload.Bucket, Key: upload.Key}

	xmlEncoder := encoding.XmlEncoder{}
	xml, err := xmlEncoder.Encode(&result)
	if err != nil {
		panic(err)
	}
	return 201, xml
}