xiongzhu 4 лет назад
Родитель
Сommit
bdda3d6ec1

+ 2 - 2
src/main/java/com/izouma/nineth/service/AssetMintService.java

@@ -19,7 +19,6 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.context.ApplicationContext;
 import org.springframework.retry.annotation.Backoff;
 import org.springframework.retry.annotation.Retryable;
-import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
 import java.io.File;
@@ -94,7 +93,7 @@ public class AssetMintService {
 
     public String ipfsUpload(String url) {
         try {
-            IPFS ipfs = new IPFS("112.74.34.84", 5001);
+            IPFS ipfs = new IPFS("120.24.204.226", 5001);
             HttpRequest request = HttpRequest.get(url);
             File file = File.createTempFile("ipfs", ".tmp");
             request.receive(file);
@@ -102,6 +101,7 @@ public class AssetMintService {
             MerkleNode put = ipfs.add(file1).get(0);
             Multihash multihash = ipfs.pin.add(put.hash).get(0);
             log.info("上传ipfs成功 {}", multihash.toBase58());
+            file.delete();
             return multihash.toBase58();
         } catch (Exception e) {
         }

+ 5 - 0
src/test/java/com/izouma/nineth/service/AssetMintServiceTest.java

@@ -13,4 +13,9 @@ public class AssetMintServiceTest extends ApplicationTests {
     @Test
     public void mint() {
     }
+
+    @Test
+    public void ipfsUpload() {
+        assetMintService.ipfsUpload("https://raex-meta.oss-cn-shenzhen.aliyuncs.com/nft/2022-01-16-00-49-11HVgyXDDl.png?x-oss-process=image/resize,h_800,m_lfit");
+    }
 }