@@ -194,6 +194,11 @@ func setupHandlers(r *mux.Router) {
194194RateLimitByGeneralRL (common .ToJSONResponse (WithConnection (RevokeShare )))).
195195Methods (http .MethodOptions , http .MethodDelete )
196196
197+ // list files shared in this allocation
198+ r .HandleFunc ("/v1/marketplace/shareinfo/{allocation}" ,
199+ RateLimitByGeneralRL (common .ToJSONResponse (WithConnection (ListShare )))).
200+ Methods (http .MethodOptions , http .MethodGet )
201+
197202// lightweight http handler without heavy postgres transaction to improve performance
198203
199204r .HandleFunc ("/v1/writemarker/lock/{allocation}" ,
@@ -648,7 +653,43 @@ func InsertShare(ctx context.Context, r *http.Request) (interface{}, error) {
648653return map [string ]interface {}{"message" : "Share info added successfully" }, nil
649654}
650655
651- //PrintCSS - print the common css elements
656+ // ListShare a list of files that clientID has shared
657+ func ListShare (ctx context.Context , r * http.Request ) (interface {}, error ) {
658+
659+ ctx = setupHandlerContext (ctx , r )
660+
661+ var (
662+ allocationID = ctx .Value (constants .ContextKeyAllocation ).(string )
663+ clientID = ctx .Value (constants .ContextKeyClient ).(string )
664+ )
665+
666+ allocationObj , err := storageHandler .verifyAllocation (ctx , allocationID , true )
667+ if err != nil {
668+ return nil , common .NewError ("invalid_parameters" , "Invalid allocation id passed." + err .Error ())
669+ }
670+
671+ sign := r .Header .Get (common .ClientSignatureHeader )
672+
673+ valid , err := verifySignatureFromRequest (allocationID , sign , allocationObj .OwnerPublicKey )
674+ if ! valid || err != nil {
675+ return nil , common .NewError ("invalid_signature" , "Invalid signature" )
676+ }
677+
678+ if clientID != allocationObj .OwnerID {
679+ return nil , common .NewError ("invalid_client" , "Client has no access to share file" )
680+ }
681+
682+ shares , err := reference .ListShareInfoClientID (ctx , clientID )
683+ if err != nil {
684+ Logger .Error ("failed_to_list_share" , zap .Error (err ))
685+ return nil , common .NewError ("failed_to_list_share" , "failed to list file share" )
686+ }
687+
688+ // get the files shared in that allocation
689+ return shares , nil
690+ }
691+
692+ // PrintCSS - print the common css elements
652693func PrintCSS (w http.ResponseWriter ) {
653694fmt .Fprintf (w , "<style>\n " )
654695fmt .Fprintf (w , ".number { text-align: right; }\n " )
0 commit comments