title: Django - edit uploaded file Before final saving
body: <p>i'm making a site for uploading and processing of files (mostly images but also other stuff). sometimes, some files need some editing before saving.
  i want edit the uploaded file before saving it to media dir (mostly to avoid IO interaction and only keep original file in memory and discard after saving edit version).</p>
  
  <p>edit: so i thought i have to run the edit function in POST, and change information in request.FILES. but i failed, and don't know what to do anymore.</p>
  
  <p>NOTE: i'm mostly looking for a way to do it via class views.</p>
  
  <p>here's some code for reference:</p>
  
  <p>The model:</p>
  
  <pre><code>class FilePatient(models.Model):
      file_imag = models.FileField(upload_to='')
  </code></pre>
  
  <p>The View:</p>
  
  <pre><code>class FileAddView(LoginRequiredMixin, UserPassesTestMixin, SuccessMessageMixin, CreateView):
      model = FilePatient
      fields = ['file_imag']
  
      def post(self, request, *args, **kwargs):
          if request.FILES['file_imag'].name.endswith('.png'):
              newFile=editFile(request.FILES['image_imag'])
              # what to do, what not to do
  
          return super().post(request, *args, **kwargs)
  </code></pre>