-
Notifications
You must be signed in to change notification settings - Fork 0
/
store.sol
34 lines (29 loc) · 926 Bytes
/
store.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract FileStorage {
struct File {
uint256 blockNumber;
uint256 fileDate;
uint256 fileLength;
address owner;
string fileName;
}
event Upload(uint256 indexed fileIndex, string indexed fileName, address indexed owner, bytes fileContent);
File[] public files;
function getAllFiles() public view returns(File[] memory) {
return files;
}
function storeFile(string calldata fileName, bytes calldata fileContent)
external
{
uint256 length = files.length;
File memory file;
file.blockNumber = block.number;
file.fileDate = block.timestamp;
file.fileName = fileName;
file.owner = msg.sender;
file.fileLength = fileContent.length;
files.push(file);
emit Upload(length, fileName, msg.sender, fileContent);
}
}