Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Add endpoint for getting uploadurl with md5 and size

Neeraj Gupta93e790b2d911
diff --git a/server/cmd/museum/main.go b/server/cmd/museum/main.go
index d7f1d88366..4a44b59ffa 100644
--- a/server/cmd/museum/main.go
+++ b/server/cmd/museum/main.go
@@ -714,6 +714,7 @@ func main() {
publicCollectionAPI.GET("/diff", publicCollectionHandler.GetDiff)
publicCollectionAPI.GET("/info", publicCollectionHandler.GetCollection)
publicCollectionAPI.GET("/upload-urls", publicCollectionHandler.GetUploadUrls)
+ publicCollectionAPI.POST("/upload-url", publicCollectionHandler.GetUploadURLV2)
publicCollectionAPI.GET("/multipart-upload-urls", publicCollectionHandler.GetMultipartUploadURLs)
publicCollectionAPI.POST("/file", publicCollectionHandler.CreateFile)
publicCollectionAPI.POST("/verify-password", publicCollectionHandler.VerifyPassword)
diff --git a/server/pkg/api/public_collection.go b/server/pkg/api/public_collection.go
index d1d6da822e..5d51163f16 100644
--- a/server/pkg/api/public_collection.go
+++ b/server/pkg/api/public_collection.go
@@ -137,6 +137,27 @@ func (h *PublicCollectionHandler) GetUploadUrls(c *gin.Context) {
})
}
+// GetUploadURLV2 returns a single upload URL that enforces checksum + content-length headers
+func (h *PublicCollectionHandler) GetUploadURLV2(c *gin.Context) {
+ enteApp := auth.GetApp(c)
+ var req ente.UploadURLRequest
+ if err := c.ShouldBindJSON(&req); err != nil {
+ handler.Error(c, stacktrace.Propagate(err, ""))
+ return
+ }
+ collection, err := h.Controller.GetPublicCollection(c, true)
+ if err != nil {
+ handler.Error(c, stacktrace.Propagate(err, ""))
+ return
+ }
+ url, err := h.FileCtrl.GetUploadURLWithMetadata(c, collection.Owner.ID, req, enteApp)
+ if err != nil {
+ handler.Error(c, stacktrace.Propagate(err, ""))
+ return
+ }
+ c.JSON(http.StatusOK, url)
+}
+
// GetMultipartUploadURLs returns upload Urls where files can be uploaded
func (h *PublicCollectionHandler) GetMultipartUploadURLs(c *gin.Context) {
enteApp := auth.GetApp(c)