Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue while uploading Image #430

Open
ApporioInfolabs opened this issue Jun 18, 2019 · 12 comments
Open

Issue while uploading Image #430

ApporioInfolabs opened this issue Jun 18, 2019 · 12 comments

Comments

@ApporioInfolabs
Copy link

Sir,
Library throws an Exception Illegal State Exception (closed) while uploading the file as multipart.
Please check

@amitshekhariitbhu
Copy link
Owner

Can you please provide me more detail like request?

@philblais
Copy link

philblais commented Aug 13, 2019

I am having the same issue, here's an what I am doing, hope this helps:

val imageFile = File(uri.path!!)
if (imageFile.exists()) {
     println("imageFile check $imageFile")
} else {
     println("imageFile does not exist")
}

I do get confirmation that file exists and I made myself an Alertview to confirm that the Uri I am using points to the correct image.

Then using the file I send an upload request with your wonderful Library:

AndroidNetworking.upload("https://url.com/api/photo/upload")
                                     .addHeaders("Auth",  managerToken)
                                     .addMultipartParameter("parent_id", parentIdString)
                                     .addMultipartParameter("parent_type", parentTypeString)
                                    .addMultipartFile("file", imageFile)
                                    .addMultipartParameter("comment", imageCommentString)
                                    .setPriority(Priority.HIGH)
                                    .build()

I get the error message:

error: com.androidnetworking.error.ANError: java.lang.IllegalStateException: closed

This was working very well until I updated Android Studio, I'm not sure if it's a coincidence though.

@keskin
Copy link

keskin commented Jan 24, 2020

have you solved the issue?

I am getting the exact error
error: com.androidnetworking.error.ANError: java.lang.IllegalStateException: closed

@philblais
Copy link

have you solved the issue?

I am getting the exact error
error: com.androidnetworking.error.ANError: java.lang.IllegalStateException: closed

Keskin, is the file you are trying to upload a saved photo uri?

@keskin
Copy link

keskin commented Jan 25, 2020

Yes, it is a photo from the gallery. I am using Rx2AndroidNetworking

Rx2AndroidNetworking.upload(ApiEndPoint.ENDPOINT_UPLOAD_PHOTO)
                .setOkHttpClient(okHttpClient)
                .addMultipartFile("file", file)
                .build()
                .getObjectObservable(ApiResponse.class);

When I check out Stetho, I can see that it generates the request with headers, but I see that the response is empty. I think it can't send to the server. When I check the server logs, I see that this request has not been received.

@keskin
Copy link

keskin commented Jan 25, 2020

I have disabled stetho in okHttpClient and now it is working.
Is there any way to get this done without disabling the logging?

@ModoumbeneDIOUF
Copy link

I have the same problem

1 similar comment
@ModoumbeneDIOUF
Copy link

I have the same problem

@nirmalrevar
Copy link

I am also facing same problem.

@itinnovertech
Copy link

I am getting this error

com.androidnetworking.error.ANError: com.androidnetworking.error.ANError: java.io.FileNotFoundException: /document/document:57027: open failed: ENOENT (No such file or directory)

here is my code:

AndroidNetworking.upload(Config.add_assignment)
.addMultipartParameter("subject_id", getSubjectId)
.addMultipartParameter("subject_name",getSubjectName)
.addMultipartFile("assigment", new File(PathHolder))
// .addMultipartFile("assigment", new File(encodedPdf))
.setContentType("Content-type: multipart/form-data; charset=utf-8")
.setTag("addAssignment")
.setPriority(Priority.MEDIUM)
.build()

 .getAsString(new StringRequestListener() {
                @Override
                public void onResponse(String response) {
                    Toast.makeText(AddPdf_StudyMaterialActivity.this,"File Uploaded Successfully......!", Toast.LENGTH_SHORT).show();
                    Intent intent=new Intent(AddPdf_StudyMaterialActivity.this, StudyPortalActivity.class);
                    startActivity(intent);
                    finish();
                }

@spapapan
Copy link

I am also having the same problem. Is there any solution for this?

@inyong1
Copy link

inyong1 commented Aug 5, 2021

I am also having the same problem. Is there any solution for this?

maksure logging feature is not active

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants