As far as i know solidity doesn't support passing an array of strings into a function ?
My issue is that i just added an array of strings (hashs from ipfs) into my struct and i am used to use the constructor to either create or update my data
like this User storage x = User(_id,_someting); and now i can not pass the array into User. any simple way to go over this or how can kepp the files outside the struct but somehow link it with the id to the struct?
struct User{
unit256 id,
unit256 someting,
string [] files,
}
Best Answer
The
struct
merely defines a type. You'll need to lay out storage to hold the users. These patterns might give you some ideas: Are there well-solved and simple storage patterns for Solidity?You can't pass an array of strings because strings are variable length and the array itself would be variable length - a variable length array of variable length elements. This is not (yet) supported by the interface.
In any case, you can work it out with functions designed to deal with one instance at a time.
For example (simplified) ...
... where user exists, add the new file hash to the array.
This is set up so we don't expect to populate everything in one move. Instead, we rely on the client to make multiple small transactions that address parts of the larger process.
Hope it helps.