Image resize on client side upon upload. fixed race condition happening on setting contronller by using chained promises.