I am new to blockchain technology and Ethereum. Have downloaded Mist and mined some ether in the testnet Ropsten, also made a greeter contract just to get the feeling of it. What I want to do is to make a contract that gives either a copy of a file (mp3 music file or jpg image file) or access to streaming this file. I can't seem to find any information about this. In Solidity, is it not possible to get files from a folder on your computer? That the contract can put into the blockchain? There is an option in the Mist meny for "upload to Swarm", where I understood I could have put my image or music file and have a contract interact with it, but this option doesn't let me choose any filetypes on my computer, it only browses folders and shows no content in any of them.

Any help is appreciated!

Ps: I know that the blockchain is not supposed to be storing a lot of data, the file in question is 547 kb and ment to be used as a test case for small files just to see if it works and how it would work.

1 Answer 1


In Solidity it is not possible to access files on your computer. This is because when your contract runs, it is being run on the global, distributed computer that works as the "Ethereum Virtual Machine".

You could, in theory, put a local file onto the blockchain in a contract as a series of bytes, but it would be very expensive in gas usage and it would be very cumbersome to read/write to once it is on the blockchain.

A simpler solution would be to store a URL to where you could find this file. If you wanted to keep it distributed, you could upload it to IPFS (or Swarm) and store a link to that in your contract.

  • Follow up; do you have any examples of Solidity and URL? Couldn't find any and have been searching around now for a while. Was thinking I could have the file(s) in a shared Dropbox folder and put an URL to this in the contract.
    – Cec
    Commented Oct 6, 2017 at 10:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.