s3: Refactor calculating path from relative_fid into a separate function