This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ exit | |
$ docker container ls -a | |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | |
8cfa3f87b3c4 iconloop/tbears "entry.sh" About an hour ago Up 42 minutes 0.0.0.0:9000->9000/tcp local-tbears |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker run -it --name local-tbears -p 9000:9000 iconloop/tbears | |
... | |
... | |
Started tbears service successfully |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/file', methods=["POST"]) | |
def upload_file(): | |
if "user_file" not in request.files: | |
return "No user_file key in request.files" | |
file = request.files["user_file"] | |
if file.filename == "": | |
return "Please select a file" | |
# get url from s3 | |
output = upload_to_aws_s3(file, S3_BUCKET) | |
return str(output) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def upload_to_aws_s3(file): | |
s3.upload_fileobj( | |
file, | |
S3_BUCKET, | |
file.filename, | |
ExtraArgs={ | |
"ACL": acl | |
"ContentType": file.content_type | |
} | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
# AWS Creds | |
S3_BUCKET = "BUCKET_NAME" | |
S3_KEY = "BUCKET_ACCESS_KEY" | |
S3_SECRET = "BUCKET_SECRET_KEY" | |
# Create boto3 client connection | |
s3 = boto3.client( | |
"s3", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip3 install boto3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EOSIO_DISPATCH( eosio::token, (create)(issue)(transfer) ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void token::transfer( name from, | |
name to, | |
asset quantity, | |
string memo ) | |
{ | |
eosio_assert( from != to, "cannot transfer to self" ); | |
require_auth( from ); | |
eosio_assert( is_account( to ), "to account does not exist"); | |
auto sym = quantity.symbol.code(); | |
stats statstable( _self, sym.raw() ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void token::issue( name to, asset quantity, string memo ) | |
{ | |
auto sym = quantity.symbol; | |
eosio_assert( sym.is_valid(), "invalid symbol name" ); | |
eosio_assert( memo.size() <= 256, "memo has more than 256 bytes" ); | |
stats statstable( _self, sym.code().raw() ); | |
auto existing = statstable.find( sym.code().raw() ); | |
eosio_assert( existing != statstable.end(), "token with symbol does not exist, create token before issue" ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void token::create( name issuer, | |
asset maximum_supply ) | |
{ | |
require_auth( _self ); | |
auto sym = maximum_supply.symbol; | |
eosio_assert( sym.is_valid(), "invalid symbol name" ); | |
eosio_assert( maximum_supply.is_valid(), "invalid supply"); | |
eosio_assert( maximum_supply.amount > 0, "max-supply must be positive"); |