简体   繁体   中英

Caused by: java.io.IOException: File /tmp/lp/LP.2015.4.28.10.29.40.zip is not a file or doesn't exist

This is how my code looks

protected Response uploadFile(final File file) throws HttpUploadException {
    System.out.println("Uploader uploading " + file.getAbsolutePath());
    System.out.println("Uploader file exists " + file.exists());
    final String endPoint = endPoint.getAppURL() + "/" + uri;
    final Response response;
    try {
      response =
          remoteResource.uploadFileAndGetResponse(endPoint, file.getAbsoluteFile(), "application/octet-stream",
                                                         Collections.<String, String>emptyMap());

    } catch (final Exception e) {
      throw new HttpUploadException("Failed to upload data to " + endPoint, e);
    }
}

When I run this code, I see

Uploader uploading /tmp/lp/LP.2015.4.28.10.29.40.zip
Uploader file exists true

and then I see exception as

com.pro.logs.client.HttpUploadException: Failed to upload data to https://mystat.pro.net:443/importer
    at com.shn.logs.common.Uploader.uploadFile(Uploader.java:54)
    at com.pro.logs.controller.report.LPDiagnosticReportUploader.upload(LPDiagnosticReportUploader.java:12)
    at com.pro.logs.controller.report.ReportSender$ReportSenderRunnable.executeTasks(ReportSender.java:109)
    at com.pro.logs.controller.report.ReportSender$ReportSenderRunnable.run(ReportSender.java:92)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: File /tmp/lp/LP.2015.4.28.10.29.40.zip is not a file or doesn't exist
    at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.construct(NettyAsyncHttpProvider.java:891)
    at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.buildRequest(NettyAsyncHttpProvider.java:657)
    at com.ning.http.client.providers.netty.NettyConnectListener$Builder.build(NettyConnectListener.java:145)
    at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.doConnect(NettyAsyncHttpProvider.java:1071)
    at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.execute(NettyAsyncHttpProvider.java:940)
    at com.ning.http.client.AsyncHttpClient.executeRequest(AsyncHttpClient.java:499)
    at com.ning.http.client.AsyncHttpClient$BoundRequestBuilder.execute(AsyncHttpClient.java:229)
    at com.shn.util.RemoteResourceManager.uploadFileAndGetResponse(RemoteResourceManager.java:137)
    at com.pro.logs.common.Uploader.uploadFile(Uploader.java:50)
    ... 6 more

When the file already exists, what's the issue?

I figured that is becauze ZIP file is not a File

System.out.println("Uploader file isFile? " + file.isFile());

I see

Uploader file isFile? false

I have a different problem now

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM