The request for a visa must be lodged at the Spanish Consulate where the applicant is resident [Jurisdiction].
If the applicant is not a permanent resident the application will have to be referred to the corresponding Spanish Embassy or Consulate and may be refused.