# stuck with permissions in using FileUtils

**URL:** <https://discuss.rubyonrails.org/t/stuck-with-permissions-in-using-fileutils/59812>\
**Category:** rubyonrails-talk\
**Created:** [July 11, 2011, 5:45pm UTC](https://discuss.rubyonrails.org/t/stuck-with-permissions-in-using-fileutils/59812 "2011-07-11T17:45:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erwin1](https://avatars.discourse-cdn.com/v4/letter/e/d07c76/32.png) [@Erwin1](https://discuss.rubyonrails.org/u/Erwin1)\
**Post date:** [July 11, 2011, 5:45pm UTC](https://discuss.rubyonrails.org/t/stuck-with-permissions-in-using-fileutils/59812/1 "2011-07-11T17:45:02Z")

</div>

Even if I am using PaperClip & Delayed\_job, I guess the issue maybe solved by FileUtisl gurus ...

here is the case :

I am testing a delayed video format transcoding , transcoding works perfectly but I get an issue -trying to write back the transcoded video from a tmp directory into the PaperClip path

the original uploaded video file is stored into the :url =\> "/system/ clips/:data/65/original/swing.avi",

in the delayed\_job, I get the clip : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;clip = Clip.find(65) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@clip\_file = clip.data.path # =\> ( ".. rails/myapp/public/ system/clips/data/65/original/NickFaldo.avi" ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@clip\_dir = File.dirname(@clip\_file) # =\> (".. /ls/myapp/ public/system/clips/data/65/original" ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;basename = File.basename(@clip\_file, File.extname(@clip\_file)) # =\> NickFaldo

the ffmpeg transcoding process, is writing an output file into the tmp dir , without any problem &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@tmp\_dir = FileUtils.mkdir\_p(Rails.root.join("tmp", "converted", "#{clip[:id]}")) # =\> ( "../clips/tmp/65i" ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@tmp\_file = File.join(@tmp\_dir, "#{basename}.mp4") # =\> ( "../clips/tmp/65/NickFaldo.mp4" )

until then everything works as expected ...

then I want to bring back the transcoded clip in place of the original one ... with the same base name but with an .mp4 extension &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@converted\_file = File.join(File.dirname(@clip\_file), "#{basename}.mp4" ) # =\> ( ".. rails/myapp/public/system/clips/ data/65/original/NickFaldo.mp4" )

so I wrote : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FileUtils.rm @clip\_file # remove clip\_file # to remove the previous original &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FileUtils.chmod(0777, @clip\_dir ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FileUtils.cp @tmp\_file, @converted\_file # copy transcoded file as new original &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FileUtils.rm\_r @tmp\_dir # remove tmp directory

but I get an \<Errno::EACCES:0x00000007820b98\> exception raised ( not being root I believe I can't change the permissions and write into the PaperClip path for this clip ....

any suggestion will be welcome ... thanks
