Create a file
Call the .submit() function to create a store object and save a file.
Returns
The function returns the store object that was just created with a couple of extra attributes.
Usage
Required parameters
Parameter | Description |
---|---|
address - string | Most likely your address |
Other parameters
In addition to the required parameters above, an object of optional parameters can be passed following the address like so:
store.submit(address,
{api_server: "https://api2.aleph.im"}
)
file_hash - string - REQUIRED if no
fileobject
Default: None
file_hash is ignored if a fileobject is passed in. Use this if you already have uploaded the file to storage or ipfs yourself.fileobject - bytes - REQUIRED if no
file_hash
Default: None
The file you want to store.
This takes precedence over the
file_hash
api_server - string
Default: "https://api1.aleph.im
Select an API server accepting files.ex: https://api1.aleph.im and "https://api2.aleph.im" are two available API servers accepting files.
chain - string
Default: null
The chain used by the sender's account. Value can beNULS2
,ETH
,DOT
,CSDK
,SOL
,AVAX
.channel - string
Default: null
Channel of the message. Ideally, an application would decide and use one channel.storage_engine - string
Default: "storage"
Storage engine to use. Use "storage" for aleph.im built-in storage or "ipfs" for an ipfs compatible storage. Possible values:storage
,ipfs
account - Account
Default: null
Account to use for signing.
âšī¸ Needed if you want to send the message. Without it, it is a dry run.
extra_fields - object
Default: {}
Any custom fields to save alongside the file in the message item_content.
If you've already stored a file in an IPFS storage, you can still create a file using the .submit() to "pin" it, by passing the: { ..., storage_engine: "ipfs" , file_hash: _ <_ipfs item hash> , ... }
See how to push a file in IPFS file storage.
Aleph file storage example
In the response, content.item_hash can be used to retrieve the stored file via a direct URL as follow:
https://<API SERVER URL>/api/v0/storage/raw/<FILE ITEM HASH HERE>
Api server can be any api server accepting files.
IPFS file storage example
Files are available at two URLs in this case:
The IPFS URL: https://ipfs.io/ipfs/<FILE ITEM HASH HERE>
The API server URL: https://<FILE API_SERVER>/api/v0/storage/raw/<FILE ITEM HASH HERE>
Last updated