@@ -101,18 +101,29 @@ func SetGateway(domain string) error {
101101 return nil
102102}
103103
104- func GetAccessLink (cid string , expires int ) (types.GetSignedURLResponse , error ) {
104+ func GetAccessLink (cid string , expires int , network string ) (types.GetSignedURLResponse , error ) {
105105
106106 jwt , err := common .FindToken ()
107107 if err != nil {
108108 return types.GetSignedURLResponse {}, err
109109 }
110110
111+ networkParam , err := config .GetNetworkParam (network )
112+ if err != nil {
113+ return types.GetSignedURLResponse {}, err
114+ }
115+
111116 domain , err := FindGatewayDomain ()
112117 if err != nil {
113118 return types.GetSignedURLResponse {}, err
114119 }
115120
121+ if networkParam == "public" {
122+ url := fmt .Sprintf ("https://%s/ipfs/%s" , domain , cid )
123+ fmt .Println (url )
124+ return types.GetSignedURLResponse {}, err
125+ }
126+
116127 domainUrl := fmt .Sprintf ("https://%s/files/%s" , domain , cid )
117128
118129 currentTime := time .Now ().Unix ()
@@ -130,7 +141,7 @@ func GetAccessLink(cid string, expires int) (types.GetSignedURLResponse, error)
130141 return types.GetSignedURLResponse {}, errors .Join (err , errors .New ("Failed to marshal paylod" ))
131142 }
132143
133- url := fmt .Sprintf ("https://%s/v3/files/download_link" , config .GetAPIHost ())
144+ url := fmt .Sprintf ("https://%s/v3/files/private/ download_link" , config .GetAPIHost ())
134145 req , err := http .NewRequest ("POST" , url , bytes .NewBuffer (jsonPayload ))
135146 if err != nil {
136147 return types.GetSignedURLResponse {}, errors .Join (err , errors .New ("failed to create the request" ))
@@ -187,7 +198,7 @@ func OpenCID(cid string, network string) error {
187198 }
188199 return nil
189200 } else {
190- data , err := GetAccessLink (cid , 30 )
201+ data , err := GetAccessLink (cid , 30 , network )
191202 if err != nil {
192203 return fmt .Errorf ("problem creating URL: %w" , err )
193204 }
0 commit comments