Gradient fill following a complex curve

Is there a was to have gradient fill that follwos a curve.  exapmple

Create a narrow retangle object cover to curves and then bend the object to a curve for example an 's'

when fill with linear gradient fill the fill flows only on the direct assigned in the fill properties...so if the object is horizontal and a curve added tot he centre the fill is only horizontal....

 my question how can I get the fill to follow the conplex curve and maintain the colours assigned to the gradient