Here is an article to describe everything about gas and how to calculate it.
Suppose, we are adding two numbers and for that the contract must do
the following actions:
Storing 10 in a variable. Let’s say this operation costs 45 gas.
Adding two variables, let’s say this costs 10 gas. Storing the result
which again costs 45 gas.
Suppose the sender specifies a gas limit of 120 gas.
The total gas used by the miner to run the computation is (45+10+45) =
100 gas.
The fee that is owed to the miner, assuming 1 gas costs 20 Gwei, is
(100 * 20 Gwei) = 0.000002 ETH.
And here you can get GAS calculations
Short answer is don't store chunks of files in the blockchain. It's not well-suited for this purpose.
Better answer. It helps to consider separate concerns:
- Smart Contracts. Minimalist data that must be true for all users at all times. Focus is on fidelity, as it's extremely difficult to post false data into a contract that's careful about updates.
- Distributed Storage of large objects. Swarm, Storj and IPFS are examples of distributed object storage/distributed file system. They use various strategies for smearing out copies and shards across participating nodes, but they are not putting all things in all places at all times.
At a very high level, we can consider a combination of these approaches. A distributed storage system can provide resilient storage of a blob, media, or JSON object with a lot of data, known by it's file name or path; a unique identifer.
A Smart Contract can track the identifier of the object that is valid, now. It can hold a validation hash useful for confirming that the correct data has been loaded from the "other" source.
For example, one might have a contract that says "There is a movie called HomeMovie" located at "url ..." and its hash is "0x456" and this is the "valid" object as of this time. If an authorized user changes the file (version), they would update the Smart Contract; "Now, the movie we're using is HomeMovie2 located at "new url ..." and its hash is "0x567".
This keeps the Ethereum storage to a minimum, while providing a way to confirm no corruption of the data in the overall system. There is an extensive assortment of projects working toward a unified view of things; that is, one interface that does it all.
Hope it helps.
Update: See Blog: Simple Storage Patterns in Solidity
Best Answer
You can store data in the blockchain:
To store your data in a special place 1 you'll need to create a contract and deploy it on the blockchain.
To store your data in a special place 2 you'll need to send someone a transaction and include your data in it.
Before you you can interact with the blockchain you will need to get access to the web3 object. There are multiple ways of doing so. I'd suggest you installing MetaMask plugin for Chrome browser. After you install it, you will have access to web3 object. The ways of interacting with web3 object can be found here (web3 api documentation)
Now that you've installed MetaMask plugin. Choose Morden testnet in the configs. Now you can use solidity browser compiler. Try to compile and deploy a simple contract there:
You will need some ether in your account(MetaMask provided account) to deploy contracts. Go to https://morden.ether.camp/ and get 5 testnet ether for free.