|
|
@ -1,4 +1,4 @@
|
|
|
|
package storage
|
|
|
|
package api
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"crypto/sha256"
|
|
|
|
"crypto/sha256"
|
|
|
@ -11,15 +11,11 @@ import (
|
|
|
|
|
|
|
|
|
|
|
|
"git.sp4ke.com/sp4ke/bit4sat/db"
|
|
|
|
"git.sp4ke.com/sp4ke/bit4sat/db"
|
|
|
|
"git.sp4ke.com/sp4ke/bit4sat/ln"
|
|
|
|
"git.sp4ke.com/sp4ke/bit4sat/ln"
|
|
|
|
|
|
|
|
"git.sp4ke.com/sp4ke/bit4sat/storage"
|
|
|
|
"git.sp4ke.com/sp4ke/bit4sat/utils"
|
|
|
|
"git.sp4ke.com/sp4ke/bit4sat/utils"
|
|
|
|
"github.com/gin-contrib/sessions"
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
|
|
|
SessLastUploadName = "last-upload"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type UploadCtrl struct{}
|
|
|
|
type UploadCtrl struct{}
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: tell client to avoid sending duplicate if we already have hash
|
|
|
|
//TODO: tell client to avoid sending duplicate if we already have hash
|
|
|
@ -34,7 +30,7 @@ func (ctrl UploadCtrl) New(c *gin.Context) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Create unique id
|
|
|
|
// Create unique id
|
|
|
|
uploadId, err := GetShortId()
|
|
|
|
uploadId, err := storage.GetShortId()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -56,7 +52,7 @@ func (ctrl UploadCtrl) New(c *gin.Context) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Create new upload
|
|
|
|
// Create new upload
|
|
|
|
up := &Upload{}
|
|
|
|
up := &storage.Upload{}
|
|
|
|
up.UploadId = uploadId
|
|
|
|
up.UploadId = uploadId
|
|
|
|
up.AskFee = uploadForm.RequestPayment
|
|
|
|
up.AskFee = uploadForm.RequestPayment
|
|
|
|
up.AskCurrency = uploadForm.PaymentCurrency
|
|
|
|
up.AskCurrency = uploadForm.PaymentCurrency
|
|
|
@ -64,7 +60,7 @@ func (ctrl UploadCtrl) New(c *gin.Context) {
|
|
|
|
|
|
|
|
|
|
|
|
// Generate unique download id
|
|
|
|
// Generate unique download id
|
|
|
|
//
|
|
|
|
//
|
|
|
|
dlId, err := GetShortId()
|
|
|
|
dlId, err := storage.GetShortId()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -80,7 +76,7 @@ func (ctrl UploadCtrl) New(c *gin.Context) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, file := range uploadForm.Files {
|
|
|
|
for _, file := range uploadForm.Files {
|
|
|
|
fup := &FileUpload{}
|
|
|
|
fup := &storage.FileUpload{}
|
|
|
|
fup.UploadId = uploadId
|
|
|
|
fup.UploadId = uploadId
|
|
|
|
|
|
|
|
|
|
|
|
fup.FileName, fup.FileExt = utils.CleanFileName(file.Name)
|
|
|
|
fup.FileName, fup.FileExt = utils.CleanFileName(file.Name)
|
|
|
@ -104,34 +100,47 @@ func (ctrl UploadCtrl) New(c *gin.Context) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Set upload status to new
|
|
|
|
// Set upload status to new
|
|
|
|
err = SetUploadStatus(uploadId, UpNew)
|
|
|
|
err = storage.SetUploadStatus(uploadId, storage.UpNew)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Upload seems valid, handle new upload procedure
|
|
|
|
// Upload seems valid, handle new upload procedure
|
|
|
|
session := sessions.Default(c)
|
|
|
|
//
|
|
|
|
|
|
|
|
// Get the upload session
|
|
|
|
|
|
|
|
upSession, err := SessionStore.Get(c.Request, UpSessionKey)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Set the uploadId as last upload for session
|
|
|
|
// Set the uploadId as last upload for session
|
|
|
|
session.AddFlash(SessLastUploadName, uploadId)
|
|
|
|
upSession.AddFlash(uploadId)
|
|
|
|
//session.AddFlash(SessLastUploadName, uploadId)
|
|
|
|
|
|
|
|
session.Save()
|
|
|
|
err = upSession.Save(c.Request, c.Writer)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If not free upload generate a an invoice
|
|
|
|
// If not free upload generate a an invoice
|
|
|
|
// TODO: check if upload fee is free
|
|
|
|
// TODO: check if upload fee is free
|
|
|
|
if uploadForm.RequestPayment {
|
|
|
|
if uploadForm.RequestPayment {
|
|
|
|
|
|
|
|
|
|
|
|
invoice, err := ln.NewInvoiceForUpload(uploadForm.RequestPaymentAmount,
|
|
|
|
invoiceOpts := ln.InvoiceOpts{
|
|
|
|
ln.CurrencyID[uploadForm.PaymentCurrency],
|
|
|
|
Amount: uploadForm.RequestPaymentAmount,
|
|
|
|
uploadId)
|
|
|
|
Curr: ln.CurrencyID[uploadForm.PaymentCurrency],
|
|
|
|
|
|
|
|
Memo: fmt.Sprintf("bit4sat upload: %s", uploadId),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
invoice, err := ln.NewInvoice(invoiceOpts)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Update Upload Invoice
|
|
|
|
// Update Upload Invoice
|
|
|
|
err = SetUploadInvoice(uploadId, invoice)
|
|
|
|
err = storage.SetUploadInvoice(uploadId, invoice)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -148,7 +157,7 @@ func (ctrl UploadCtrl) New(c *gin.Context) {
|
|
|
|
//}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
|
|
"status": UpNew,
|
|
|
|
"status": storage.UpNew,
|
|
|
|
"invoice": invoice,
|
|
|
|
"invoice": invoice,
|
|
|
|
"upload_id": uploadId,
|
|
|
|
"upload_id": uploadId,
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -172,7 +181,7 @@ func (ctrl UploadCtrl) New(c *gin.Context) {
|
|
|
|
func (ctrl UploadCtrl) CheckStatus(c *gin.Context) {
|
|
|
|
func (ctrl UploadCtrl) CheckStatus(c *gin.Context) {
|
|
|
|
uploadId := c.Param("id")
|
|
|
|
uploadId := c.Param("id")
|
|
|
|
|
|
|
|
|
|
|
|
exists, err := IdExists(uploadId)
|
|
|
|
exists, err := storage.IdExists(uploadId)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -184,7 +193,7 @@ func (ctrl UploadCtrl) CheckStatus(c *gin.Context) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Get upload status
|
|
|
|
// Get upload status
|
|
|
|
uploadStatus, err := GetUploadStatus(uploadId)
|
|
|
|
uploadStatus, err := storage.GetUploadStatus(uploadId)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -198,7 +207,7 @@ func (ctrl UploadCtrl) CheckStatus(c *gin.Context) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Get invoice id for upload
|
|
|
|
// Get invoice id for upload
|
|
|
|
invoiceId, err := GetUploadIdInvoiceId(uploadId)
|
|
|
|
invoiceId, err := storage.GetUploadIdInvoiceId(uploadId)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -217,7 +226,7 @@ func (ctrl UploadCtrl) CheckStatus(c *gin.Context) {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
c.JSON(InvoiceHttpCode(invoice), gin.H{
|
|
|
|
c.JSON(ln.InvoiceHttpCode(invoice), gin.H{
|
|
|
|
"upload_id": uploadId,
|
|
|
|
"upload_id": uploadId,
|
|
|
|
"invoice": invoice,
|
|
|
|
"invoice": invoice,
|
|
|
|
"status": uploadStatus,
|
|
|
|
"status": uploadStatus,
|
|
|
@ -228,7 +237,7 @@ func (ctrl UploadCtrl) CheckStatus(c *gin.Context) {
|
|
|
|
func (ctrl UploadCtrl) PollStatus(c *gin.Context) {
|
|
|
|
func (ctrl UploadCtrl) PollStatus(c *gin.Context) {
|
|
|
|
uploadId := c.Param("id")
|
|
|
|
uploadId := c.Param("id")
|
|
|
|
|
|
|
|
|
|
|
|
exists, err := IdExists(uploadId)
|
|
|
|
exists, err := storage.IdExists(uploadId)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -239,13 +248,13 @@ func (ctrl UploadCtrl) PollStatus(c *gin.Context) {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uploadStatus, err := GetUploadStatus(uploadId)
|
|
|
|
uploadStatus, err := storage.GetUploadStatus(uploadId)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if uploadStatus&UpNew != 0 {
|
|
|
|
if uploadStatus&storage.UpNew != 0 {
|
|
|
|
c.JSON(http.StatusCreated, gin.H{
|
|
|
|
c.JSON(http.StatusCreated, gin.H{
|
|
|
|
"status": uploadStatus,
|
|
|
|
"status": uploadStatus,
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -253,7 +262,7 @@ func (ctrl UploadCtrl) PollStatus(c *gin.Context) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// we are not in UpNew state so we should have an invoice
|
|
|
|
// we are not in UpNew state so we should have an invoice
|
|
|
|
invoice, err := GetUploadInvoice(uploadId)
|
|
|
|
invoice, err := storage.GetUploadInvoice(uploadId)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -282,7 +291,7 @@ func (ctrl UploadCtrl) PollStatus(c *gin.Context) {
|
|
|
|
|
|
|
|
|
|
|
|
// if expired return with expired response
|
|
|
|
// if expired return with expired response
|
|
|
|
if invoice.Expired {
|
|
|
|
if invoice.Expired {
|
|
|
|
err := SetUploadStatus(uploadId, UpPayExpired)
|
|
|
|
err := storage.SetUploadStatus(uploadId, storage.UpPayExpired)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Printf("Redis error: %s", err)
|
|
|
|
log.Printf("Redis error: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -301,43 +310,51 @@ func (ctrl UploadCtrl) PollStatus(c *gin.Context) {
|
|
|
|
//
|
|
|
|
//
|
|
|
|
log.Println("POLL: invoice was paid")
|
|
|
|
log.Println("POLL: invoice was paid")
|
|
|
|
|
|
|
|
|
|
|
|
uploadStatus |= UpPaid
|
|
|
|
uploadStatus |= storage.UpPaid
|
|
|
|
err := SetUploadStatus(uploadId, uploadStatus)
|
|
|
|
err := storage.SetUploadStatus(uploadId, uploadStatus)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Printf("Redis error: %s", err)
|
|
|
|
log.Printf("Redis error: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Update Upload Invoice
|
|
|
|
// Update Upload Invoice
|
|
|
|
err = SetUploadInvoice(uploadId, invoice)
|
|
|
|
err = storage.SetUploadInvoice(uploadId, invoice)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Generate admin token and save it
|
|
|
|
// Generate admin token and save it
|
|
|
|
adminToken, err := GetLongId()
|
|
|
|
adminToken, err := storage.GetLongId()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
err = SetUploadAdminToken(uploadId, adminToken)
|
|
|
|
err = storage.SetUploadAdminToken(uploadId, adminToken)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Get the download id
|
|
|
|
// Get the download id
|
|
|
|
dlId, err := GetDownloadId(uploadId)
|
|
|
|
dlId, err := storage.GetDownloadId(uploadId)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Clear the session
|
|
|
|
// Clear the session
|
|
|
|
session := sessions.Default(c)
|
|
|
|
upSession, err := SessionStore.Get(c.Request, UpSessionKey)
|
|
|
|
session.Clear()
|
|
|
|
if err != nil {
|
|
|
|
session.Save()
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
upSession.Flashes()
|
|
|
|
|
|
|
|
err = upSession.Save(c.Request, c.Writer)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// invoice was paid
|
|
|
|
// invoice was paid
|
|
|
|
c.JSON(http.StatusAccepted, gin.H{
|
|
|
|
c.JSON(http.StatusAccepted, gin.H{
|
|
|
@ -368,7 +385,7 @@ func (ctrl UploadCtrl) Upload(c *gin.Context) {
|
|
|
|
// Check that upload ID exists
|
|
|
|
// Check that upload ID exists
|
|
|
|
uploadId := c.Param("id")
|
|
|
|
uploadId := c.Param("id")
|
|
|
|
|
|
|
|
|
|
|
|
exists, err := IdExists(uploadId)
|
|
|
|
exists, err := storage.IdExists(uploadId)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -438,7 +455,7 @@ func (ctrl UploadCtrl) Upload(c *gin.Context) {
|
|
|
|
sum256 := hex.EncodeToString(hasher.Sum(nil))
|
|
|
|
sum256 := hex.EncodeToString(hasher.Sum(nil))
|
|
|
|
|
|
|
|
|
|
|
|
// Get the file's metadata from upload table
|
|
|
|
// Get the file's metadata from upload table
|
|
|
|
up, err := GetByHashID(sum256, uploadId)
|
|
|
|
up, err := storage.GetByHashID(sum256, uploadId)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
utils.JSONErrPriv(c, http.StatusNotFound, err)
|
|
|
|
utils.JSONErrPriv(c, http.StatusNotFound, err)
|
|
|
|
db.RollbackTx(tx, nil)
|
|
|
|
db.RollbackTx(tx, nil)
|
|
|
@ -456,7 +473,7 @@ func (ctrl UploadCtrl) Upload(c *gin.Context) {
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
log.Println("Storing file")
|
|
|
|
log.Println("Storing file")
|
|
|
|
err = StoreFormFile(formFd, up.SHA256+up.FileExt)
|
|
|
|
err = storage.StoreFormFile(formFd, up.SHA256+up.FileExt)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
db.RollbackTx(tx, nil)
|
|
|
|
db.RollbackTx(tx, nil)
|
|
|
@ -464,7 +481,7 @@ func (ctrl UploadCtrl) Upload(c *gin.Context) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
log.Printf("%s stored at %s", up.FileName,
|
|
|
|
log.Printf("%s stored at %s", up.FileName,
|
|
|
|
GetStoreDestination(up.SHA256+up.FileExt))
|
|
|
|
storage.GetStoreDestination(up.SHA256+up.FileExt))
|
|
|
|
|
|
|
|
|
|
|
|
// Setting status to stored
|
|
|
|
// Setting status to stored
|
|
|
|
log.Println("Updating file upload stored status")
|
|
|
|
log.Println("Updating file upload stored status")
|
|
|
@ -475,7 +492,7 @@ func (ctrl UploadCtrl) Upload(c *gin.Context) {
|
|
|
|
|
|
|
|
|
|
|
|
// Rollback and remove the file
|
|
|
|
// Rollback and remove the file
|
|
|
|
db.RollbackTx(tx, func() {
|
|
|
|
db.RollbackTx(tx, func() {
|
|
|
|
err := os.Remove(GetStoreDestination(up.SHA256 + up.FileExt))
|
|
|
|
err := os.Remove(storage.GetStoreDestination(up.SHA256 + up.FileExt))
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Println(err)
|
|
|
|
log.Println(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -491,7 +508,7 @@ func (ctrl UploadCtrl) Upload(c *gin.Context) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Set the whole transaction as stored
|
|
|
|
// Set the whole transaction as stored
|
|
|
|
err = SetUploadStatus(uploadId, UpStored)
|
|
|
|
err = storage.SetUploadStatus(uploadId, storage.UpStored)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
utils.JSONErrPriv(c, http.StatusInternalServerError, err)
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -499,7 +516,7 @@ func (ctrl UploadCtrl) Upload(c *gin.Context) {
|
|
|
|
|
|
|
|
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
|
|
"status": http.StatusOK,
|
|
|
|
"status": http.StatusOK,
|
|
|
|
"store_status": UpStored,
|
|
|
|
"store_status": storage.UpStored,
|
|
|
|
"upload_id": uploadId,
|
|
|
|
"upload_id": uploadId,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|