you can apply from anywhere but to have your visa office as buffalo, you should have at least a year visa to canada or US and it cannot be a visitor visa. Remember the visa has to be at least a year, it doesn't mean you have to have been in canada or US for a year.
Baku Do't get desperate to go to Canada ....as i have seen your profile u r quite a young person and a life in front of you...and InshaAllha with this qualification and motivation you will get million opportunities to be settle in your life with marring a foriegner girl. it is not a good idea to go and marry a canadian girl for the pupose of visa or residence....
Acutally i have relatives who are canadian anyhow i need to marry so why not look their
But chances are less as i am planing to apply for Australian immigration