vourhey / pinatapy Goto Github PK
View Code? Open in Web Editor NEWNon-official Pinata.cloud library
License: BSD 3-Clause "New" or "Revised" License
Non-official Pinata.cloud library
License: BSD 3-Clause "New" or "Revised" License
Now we have only constant gateway: https://github.com/Vourhey/pinatapy/blob/master/pinatapy/__init__.py#L15
Pinata allows you to create custom gateways. Can we make it usable for library to prevent tons request to main point?
After the last update to properly handle options
data, providing options.pinataMetadata
(and perhaps also options.pinataOptions
) still error out.
Input:
pinata_metadata = {"pinataMetadata": { "name": "A Test File" }}
pinata.pin_json_to_ipfs(file, options=pinata_metadata)
Output:
{'status': 400, 'reason': 'Bad Request', 'text': '{"error":"Invalid JSON provided"}'}
It appears providing the metadata body as a JSON string solves this.
import json
metadata_content = { "name": "A Test File" }
pinata_metadata = {"pinataMetadata": json.dumps(metadata_content)}
pinata.pin_json_to_ipfs(file, options=pinata_metadata)
I am not sure if this should be done user-side, because this is not documented. And of course, thanks for this script!
I am wondering if you could help. Previously I was uploading a directory via pin_file_to_ipfs and the URL would be hash/filename. Now it has changed to hash/fullpath/filename. Is there anyway to remove the fullpath and revert back to the /hash/filename?
Thanks for the SDK, it works very well. When i give the path to the folder it looks something like
/Users/username/folder/
when i upload a folder manually it will resolve all files to be in root such that when i open the gateway url with my hash i get immediately the contents i am looking for.
the sdk is currently creating a folder structure where it takes a few layers to go from root hash to my contents.
this is important i believe as the merkle tree takes a longer time to build the more layers it has.
is there a way I can accomplish this? perhaps i am using your library incorrectly?
would greatly appreciate your help.
Hi. There is an issue with file upload. It uploads the first one but returns an error message for all the following.
>>> from pinatapy import PinataPy
>>> pinata = PinataPy(API_KEY, API_SECRET)
>>> pinata.pin_file_to_ipfs(path_to_file)
{'IpfsHash': 'Qm...',
'PinSize': ...,
'Timestamp': '...',
'isDuplicate': True}
>>> pinata.pin_file_to_ipfs(path_to_file)
{'status': 400, 'reason': 'Bad Request', 'text': '{"error":{"reason":"UNKNOWN_REASON","details":"Unexpected token - in JSON at position 0"}}'}
Python: 3.9.9
pinatapy-vourhey: 29ad523
Hello,
i have tried using a folder but im sadly getting the entire /home/documents/ ecc. that i would like to "hide"
is there a way to avoid uploading the entire path of the folder?
thank you for this nice library
edit1: i tried changing to res = requests.post(self.__endpoint + url_suffix, files=files, data/params = options, headers=self.headers)
to pass wrapWithDirectory = false
but im always the the same cid with same directory, i also tried on files["pinataOptions"] to add the wrapWithDirectory = false but always getting the same cid with the path
Edit2:
i manged to do it with:
files = [("file",(str(pathlib.PurePath(file).parent.name + "/"+ pathlib.PurePath(file).name), open(file, "rb"))) for file in path_to_file.glob('*') if not file.is_dir()]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.