I need to learn how to specify the file path for files at internal storage folders. I found at Github.com the next example to compare two images:
ImagingApi imagingApi = new ImagingApi(“clientSecret”, “clientId”);
// create search context or use existing search context ID if search context was created earlier
SearchContextStatus status = imagingApi.createImageSearch(
new CreateImageSearchRequest(null, null, null, null));
String searchContextId = status.getId();
// specify images for comparing (image ID is a path to image in storage)
String imageInStorage1 = “WorkFolder/Image1.jpg”;
String imageInStorage2 = “WorkFolder/Image2.jpg”;
// compare images
SearchResultsSet result = imagingApi.compareImages(
new CompareImagesRequest(
searchContextId, imageInStorage1, null, imageInStorage2, null, null));
Double similarity = result.getResults().get(0).getSimilarity();
When I created my account I also created my App and my Storage (as internal storage) where I added the folder Test0 to upload my files and I replaced in the code of the example this line:
String imageInStorage1 = “WorkFolder/Image1.jpg”; with
String imageInStorage1 = “Test0\Foto1.png”;
But when I run my class I receive the error:
javax.imageio.IIOException: Can’t read input file!
at java.desktop/javax.imageio.ImageIO.read(ImageIO.java:1310)
at com.sipsa.tast.demos.AsposeCompare0.main(AsposeCompare0.java:30)
com.aspose.imaging.cloud.sdk.invoker.ApiException: {“requestId”:null,“error”:{“code”:“internalError”,“message”:“Dynabic.Storage.Exceptions.HttpWebException: AmazonS3 Storage exception: The specified key does not exist. Bucket ‘aspose.cloud-filestorage-prod’, FilePath ‘950619/3f16b8c6-71b6-4613-a888-0c4ac8b1238a/Test0/Foto1.png’\r\n at Dynabic.Storage.Managers.AmazonS3Manager.RunAmazonCode[T](Func1 action) in C:\\build\\src\\submodules\\Dynabic.Storage\\src\\Dynabic.Storage\\Managers\\AmazonS3Manager.cs:line 856\r\n at Aspose.Imaging.Cloud.Core.Business.ResilientStorageManager.InvokeWithRetry[T](Func
1 func, Func2 postCheck, Boolean retryFalseResult, Int32 retryCount) in C:\\build\\src\\Aspose.Imaging.Cloud.Core\\Business\\ResilientStorageManager.cs:line 434\r\n at Aspose.Imaging.Cloud.Core.Business.ResilientStorageManager.InvokeWithRetry[T](Func
1 func, Func2 postCheck, Boolean retryFalseResult, Int32 retryCount) in C:\\build\\src\\Aspose.Imaging.Cloud.Core\\Business\\ResilientStorageManager.cs:line 455\r\n at Aspose.Imaging.Cloud.Core.Business.ResilientStorageManager.InvokeWithRetry[T](Func
1 func, Func2 postCheck, Boolean retryFalseResult, Int32 retryCount) in C:\\build\\src\\Aspose.Imaging.Cloud.Core\\Business\\ResilientStorageManager.cs:line 455\r\n at Aspose.Imaging.Cloud.Core.Business.ResilientStorageManager.InvokeWithRetry[T](Func
1 func, Func2 postCheck, Boolean retryFalseResult, Int32 retryCount) in C:\\build\\src\\Aspose.Imaging.Cloud.Core\\Business\\ResilientStorageManager.cs:line 455\r\n at Aspose.Imaging.Cloud.Core.Business.ResilientStorageManager.InvokeWithRetry[T](Func
1 func, Func2 postCheck, Boolean retryFalseResult, Int32 retryCount) in C:\\build\\src\\Aspose.Imaging.Cloud.Core\\Business\\ResilientStorageManager.cs:line 455\r\n at Aspose.Imaging.Cloud.Core.Business.ResilientStorageManager.Download(String path, String versionId) in C:\\build\\src\\Aspose.Imaging.Cloud.Core\\Business\\ResilientStorageManager.cs:line 127\r\n at Aspose.Imaging.Cloud.AI.Business.SearchContextForCloud.GetImage(String id, IStorageManager fileManager) in C:\\build\\src\\Aspose.Imaging.Cloud.AI\\Business\\SearchContextForCloud.cs:line 134\r\n at Aspose.Imaging.Cloud.AI.Controllers.SearchContextController.<>c__DisplayClass5_0.<<CompareImages>b__0>d.MoveNext() in C:\\build\\src\\Aspose.Imaging.Cloud.AI\\Controllers\\SearchContextController.cs:line 230\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at Aspose.Imaging.Cloud.AI.Controllers.BaseSearchContextController.InSearchContextAsync[T](String methodName, String searchContextId, String folder, Func
2 searchContextFunc, String storage, Boolean isContextChanged)”,“description”:“Operation Failed. Internal error.”,“dateTime”:“2023-04-13T10:46:13.9774562Z”,“innerError”:null}}
at com.aspose.imaging.cloud.sdk.invoker.internal.requesthandlers.ApiExceptionRequestHandler.throwApiException(ApiExceptionRequestHandler.java:98)
at com.aspose.imaging.cloud.sdk.invoker.internal.requesthandlers.ApiExceptionRequestHandler.processResponse(ApiExceptionRequestHandler.java:71)
at com.aspose.imaging.cloud.sdk.invoker.internal.ApiInvoker.readResponse(ApiInvoker.java:448)
at com.aspose.imaging.cloud.sdk.invoker.internal.ApiInvoker.invokeInternal(ApiInvoker.java:300)
at com.aspose.imaging.cloud.sdk.invoker.internal.ApiInvoker.invokeApi(ApiInvoker.java:106)
at com.aspose.imaging.cloud.sdk.api.ImagingApi.compareImages(ImagingApi.java:279)
at com.sipsa.tast.demos.AsposeCompare0.main(AsposeCompare0.java:70)
Exception in thread “main” java.lang.NullPointerException: Cannot invoke “com.aspose.imaging.cloud.sdk.model.SearchResultsSet.getResults()” because “result” is null
at com.sipsa.tast.demos.AsposeCompare0.main(AsposeCompare0.java:77)