move file management out of rest helper

Change-Id: I7515f89470c7aba09047c111ff6d722bee927f9b
Reviewed-on: http://review.couchbase.org/37145
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Li Yang <lichenyang2@gmail.com>