Я работаю над попыткой сохранить изображения в Google Storage и нашел тестовый код на одном из их форумов.
Я добавил различные зависимости и хотел пройтись по коду, как бы я ниМы столкнулись с этим исключением, прежде чем вообще очень далеко.Я должен добавить, что это локальное тестирование, а не использование appEngine, и что я искал различные ресурсы в сети, но столкнулся с убытками.
Код, который я нашел (я изменил имя корзины и URL-адресфайла):
public static void test() throws IOException {
GcsService gcsService = GcsServiceFactory.createGcsService();
BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
GcsFileOptions options = new GcsFileOptions.Builder()
.mimeType(".jpg")
.acl("project-private")
.build();
String bucketName = "my_test_bucket";
String secureFilename = "https://helpx.adobe.com/uk/stock/how-to/visual-reverse-image-search/_jcr_content/main-pars/image.img.jpg/visual-reverse-image-search-v2_1000x560.jpg";
GcsFilename p_filename = new GcsFilename(bucketName, secureFilename);
GcsOutputChannel writeChannel = gcsService.createOrReplace(p_filename, options); //exception here
//writeChannel.write(ByteBuffer.wrap(image.getImageData()));
writeChannel.close();
BlobKey blobKey = blobstoreService.createGsBlobKey("/gs/" + p_filename.getBucketName() + "/" + p_filename.getObjectName());
ImagesService imageService = ImagesServiceFactory.getImagesService();
ServingUrlOptions servoptions = ServingUrlOptions.Builder.withBlobKey(blobKey).secureUrl(true);
String url = imageService.getServingUrl(servoptions);
}
Исключение возникает при вызове createOrReplace.
Исключение составляет:
Apr 12, 2019 4:37:48 PM com.google.appengine.tools.cloudstorage.RetryHelper doRetry
WARNING: RetryHelper(432.2 ms, 1 attempts, com.google.appengine.tools.cloudstorage.GcsServiceImpl$1@12331b): Attempt 1 failed, sleeping for 85 ms: com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call file.Create in a thread that is neither the original request thread nor a thread created by ThreadManager
Apr 12, 2019 4:37:48 PM com.google.appengine.tools.cloudstorage.RetryHelper doRetry
WARNING: RetryHelper(621.2 ms, 2 attempts, com.google.appengine.tools.cloudstorage.GcsServiceImpl$1@12331b): Attempt 2 failed, sleeping for 128 ms: com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call file.Create in a thread that is neither the original request thread nor a thread created by ThreadManager
Apr 12, 2019 4:37:48 PM com.google.appengine.tools.cloudstorage.RetryHelper doRetry
WARNING: RetryHelper(761.3 ms, 3 attempts, com.google.appengine.tools.cloudstorage.GcsServiceImpl$1@12331b): Attempt 3 failed, sleeping for 253 ms: com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call file.Create in a thread that is neither the original request thread nor a thread created by ThreadManager
Apr 12, 2019 4:37:48 PM com.google.appengine.tools.cloudstorage.RetryHelper doRetry
WARNING: RetryHelper(1.026 s, 4 attempts, com.google.appengine.tools.cloudstorage.GcsServiceImpl$1@12331b): Attempt 4 failed, sleeping for 495 ms: com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call file.Create in a thread that is neither the original request thread nor a thread created by ThreadManager
Apr 12, 2019 4:37:49 PM com.google.appengine.tools.cloudstorage.RetryHelper doRetry
WARNING: RetryHelper(1.533 s, 5 attempts, com.google.appengine.tools.cloudstorage.GcsServiceImpl$1@12331b): Attempt 5 failed, sleeping for 1278 ms: com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call file.Create in a thread that is neither the original request thread nor a thread created by ThreadManager
Apr 12, 2019 4:37:50 PM com.google.appengine.tools.cloudstorage.RetryHelper doRetry
WARNING: RetryHelper(2.824 s, 6 attempts, com.google.appengine.tools.cloudstorage.GcsServiceImpl$1@12331b): Attempt 6 failed, sleeping for 2984 ms: com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call file.Create in a thread that is neither the original request thread nor a thread created by ThreadManager
Disconnected from the target VM, address: '127.0.0.1:57754', transport: 'socket'
com.google.appengine.tools.cloudstorage.RetriesExhaustedException: RetryHelper(2.832 s, 6 attempts, com.google.appengine.tools.cloudstorage.GcsServiceImpl$1@12331b): Too many failures, giving up
at com.google.appengine.tools.cloudstorage.RetryHelper.doRetry(RetryHelper.java:100)
at com.google.appengine.tools.cloudstorage.RetryHelper.runWithRetries(RetryHelper.java:123)
at com.google.appengine.tools.cloudstorage.GcsServiceImpl.createOrReplace(GcsServiceImpl.java:32)
at gametest.Application.test(Application.java:55)
at gametest.Application.main(Application.java:69)
Caused by: com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call file.Create in a thread that is neither the original request thread nor a thread created by ThreadManager
at com.google.apphosting.api.ApiProxy$CallNotFoundException.foreignThread(ApiProxy.java:800)
at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:112)
at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:65)
at com.google.appengine.api.files.FileServiceImpl.makeSyncCall(FileServiceImpl.java:591)
at com.google.appengine.api.files.FileServiceImpl.create(FileServiceImpl.java:512)
at com.google.appengine.api.files.FileServiceImpl.createNewGSFile(FileServiceImpl.java:157)
at com.google.appengine.tools.cloudstorage.dev.LocalRawGcsService.beginObjectCreation(LocalRawGcsService.java:106)
at com.google.appengine.tools.cloudstorage.dev.LocalRawGcsService.beginObjectCreation(LocalRawGcsService.java:44)
at com.google.appengine.tools.cloudstorage.GcsServiceImpl$1.run(GcsServiceImpl.java:35)
at com.google.appengine.tools.cloudstorage.GcsServiceImpl$1.run(GcsServiceImpl.java:32)
at com.google.appengine.tools.cloudstorage.RetryHelper.doRetry(RetryHelper.java:78)
... 4 more
Process finished with exit code 0
любая помощь в разрешении будет огромной, спасибозаранее.