|
|
@@ -17,11 +17,13 @@ import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
+import org.springframework.core.env.Environment;
|
|
|
import org.springframework.retry.annotation.Backoff;
|
|
|
import org.springframework.retry.annotation.Retryable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.File;
|
|
|
+import java.util.Arrays;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
@@ -31,6 +33,7 @@ public class AssetMintService {
|
|
|
private UserRepo userRepo;
|
|
|
private NFTService nftService;
|
|
|
private ApplicationContext applicationContext;
|
|
|
+ private Environment env;
|
|
|
|
|
|
@Retryable(maxAttempts = 10, backoff = @Backoff(delay = 1000))
|
|
|
public void mint(Long assetId) {
|
|
|
@@ -93,7 +96,15 @@ public class AssetMintService {
|
|
|
|
|
|
public String ipfsUpload(String url) {
|
|
|
try {
|
|
|
- IPFS ipfs = new IPFS("120.24.204.226", 5001);
|
|
|
+ url = url.replace("raex-meta.oss-cn-shenzhen.aliyuncs.com",
|
|
|
+ "raex-meta.oss-cn-shenzhen-internal.aliyuncs.com")
|
|
|
+ .replace("cdn.raex.vip",
|
|
|
+ "raex-meta.oss-cn-shenzhen-internal.aliyuncs.com");
|
|
|
+ String host = "120.24.204.226";
|
|
|
+ if (Arrays.asList(env.getActiveProfiles()).contains("prod")) {
|
|
|
+ host = "172.29.50.102";
|
|
|
+ }
|
|
|
+ IPFS ipfs = new IPFS(host, 5001);
|
|
|
HttpRequest request = HttpRequest.get(url);
|
|
|
File file = File.createTempFile("ipfs", ".tmp");
|
|
|
request.receive(file);
|