Closed zhangchengtest closed 1 year ago
Hello @zhangchengtest . This command doesn't read the file from the file system. It is read from the body of the request. Have you tried one of the "body" methods? https://github.com/ipfs-shipyard/gomobile-ipfs/blob/2af807822a4b70cb3992b0141a3ca5906c3c2766/android/bridge/src/main/java/ipfs/gomobile/android/RequestBuilder.java#L234-L288
Hi, I use the method withBody like this
File file = new File(Environment.getExternalStorageDirectory(), fileName); InputStream inputStream = ipfs.newRequest("add").withBody(file).send();
But I got anthor error
go.Universe$proxyerror: read unix @->//data/user/0/com.cunw.peer/cache/sock/0000000: use of closed network connection
What is your test setup? Are you using an Android simulator, or connected to a real phone? Before trying new commands, do the test commands work? For example, in the packages directory:
make test_bridge.android
I use a real phone and there is another error when I use another file
go.Universe$proxyerror: Post "http://unix/api/v0/add?": EOF
We need to know if basic IPFS is working. Does make test_bridge.android
work?
not try this, but i will try later. but I have tried a lot command like ipfs get , ipfs swam peers... they all works in the app installed in my phone only the "add" not work
make test_bridge.android have no problem
follow the example it is ok. but I got the cid not same as the cid where I add the same file to computer. ` ByteArrayOutputStream outputStream = new ByteArrayOutputStream( ); outputStream.write("--------------------------5f505897199c8c52\r\n".getBytes()); outputStream.write("Content-Disposition: form-data; name=\"file\"\r\n".getBytes()); outputStream.write("Content-Type: application/octet-stream\r\n\r\n".getBytes()); outputStream.write(buffer.toByteArray()); outputStream.write("\r\n\r\n--------------------------5f505897199c8c52--".getBytes());
byte body[] = outputStream.toByteArray();
ArrayList
String cid = jsonList.get(0).getString("Hash"); Log.d(TAG, "cid is " + cid);
witbody bytes function works, but inputstream not work always throw the EOF exception in InputStreamToGo
Hello @zhangchengtest . Thank you for testing. I have reproduced your error and I created a bug report. We will look into it. https://github.com/ipfs-shipyard/gomobile-ipfs/issues/143
Hello @zhangchengtest . We merged pull request #146 to fix the EOF exception in InputStreamToGo . This test of the API now works.
Does this resolve your issue?
Bug was fixed. This issue is inactive. Presumed resolved. Closing.
Asking a question, not reporting a bug
Is there an existing issue for this?
Question
How to use "add file"
Context
ipfs.newRequest("add").withArgument(path).send(); it is not correct, is there any way to process the "add" function