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

add_bytes and add_string #188

Closed
batrlatom opened this issue Jul 11, 2019 · 4 comments
Closed

add_bytes and add_string #188

batrlatom opened this issue Jul 11, 2019 · 4 comments

Comments

@batrlatom
Copy link

batrlatom commented Jul 11, 2019

Python 3.7
py-ipfs-http-client ... last version

I have a problem with adding images in base64 format. The content is not added as a whole. Is there any limit to the size of the string or byte array?

Original to be added:
image

What was added (as an example, not exactly the same image):
image

@ntninja
Copy link
Contributor

ntninja commented Jul 11, 2019

Thanks for the report! Which version of go-ipfs are you using? There were some known issues with some recent versions regarding this.

Please run the following commands and report their results for this:

  • ipfs version (go-ipfs version)
  • python3 -c 'import ipfshttpclient; print(ipfshttpclient.__version__)' (py-ipfs-http-client version)

Will help you after this if I can!

@WouterGlorieux
Copy link
Contributor

WouterGlorieux commented Nov 18, 2019

I'm also experiencing similar behavior when trying to add a string or json object larger than 4096 characters via ipfshttpclient

i'm using:
Python 3.7
go-ipfs 0.4.22
ipfshttpclient 0.4.12

i also tried downgrading go-ipfs to earlier versions, but the behaviour was the same, string get truncated at 4096 characters

Here is a bit of code to reproduce the behaviour:

`

import ipfshttpclient

api = ipfshttpclient.connect(’/ip4/127.0.0.1/tcp/5001/http’)

length = 4097 # up to 4096 should work

original_string = ‘’.join([‘a’ for _ in range(length)])
multihash = api.add_str(original_string)

retrieved_string = api.cat(cid=multihash)

retrieved_string = retrieved_string.decode() # In python3, the retrieved string is a bytes object, so need to decode it back into a string

print(original_string)
print(retrieved_string)
assert original_string == retrieved_string

`

@WouterGlorieux
Copy link
Contributor

WouterGlorieux commented Nov 18, 2019

Just saw there is another open issue regarding this same problem:
#190

it mentions setting chunk_size when connecting to the ipfs node
client = ipfshttpclient.connect('/ip4/127.0.0.1/tcp/5001/http"', chunk_size=4096, session=True)

I have tried it and setting chunk_size to a larger number does work.

But would this cause any side effects if I set it to a very large number?

@WouterGlorieux
Copy link
Contributor

WouterGlorieux commented Nov 18, 2019

Found the problem and created a pull request:
#194

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

3 participants