Create a file

Call the .create_store() function to create a store object message and save a file.

Returns

The store object that was just created with a couple of extra attributes.

If you've already stored a file in an IPFS storage, you can still create a file using the .create_store() to "pin" it, by passing the: { ..., storage_engine: "ipfs" , file_hash: <ipfs item hash> , ... }

See how to push a file in IPFS file storage.

Usage

def create_store(
    account,
    address,
    file_content,
    file_hash,
    guess_mime_type,
    ref,
    storage_engine,
    extra_fields,
    channel,
    session,
    api_server,
)

Required Arguments

account - Account

Account the Store should be associated with or the account that submitted the Store.

Optional Arguments

  • 2. address - string Default: None Address the Store should be associated with or the address that submitted the Store. To store on behalf of an address that is not the account signing see the aggregate section on security key

  • 3. file_content - bytes Default: None File content is ignored if a file_hash is passed. The file you want to store. file_content will be pushed to either storage or ipfs function of the storage_engine chosen.

    REQUIRED if no file_hash

  • 4. file_hash - string Default: None This takes precedence over the file_content Use this if you already have uploaded the file to storage or ipfs yourself. REQUIRED if no file_content

  • 5. guess_mime_type - boolean Default: False If set to True and no mime_type is passed in the extra_fields argument, the mime_type will be set to magic.from_buffer

  • 6. ref - string Default: None if ref is present, it will be assigned to the ref key of extra_fields.

  • 7. 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

  • 8. extra_fields - dictionary Default: None

    Any custom fields to save alongside the file in the message item_content. Mime type can be passed through this { mime_type: <mime type here> }. See guess mime type argument for details.

  • 9. channel - string Default: "TEST" Channel of the message. Ideally, an application would decide and use one channel.

  • 10. session Default: None

  • 11. api_server - string Default: "https://api2.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.

Last updated