Best way of pinning

what should be actual procedure,
1)uploading file to server folder then pin that folder
2) use ipfs.add.file method, and provide random ‘path’ (i dont consider about path) as parameter ,then get hash of it and feed it to ipfs.pin.add so it will be forver in system , until i manually unpin it.

js ipfs api