Currently I am saving a file to a loal directory from a ftp server. But I want to move to using ImageFields to make things more manageable.
here is the current code snippet
file_handle = open(savePathDir +'/' + fname, "wb")
nvcftp.retrbinary("RETR " + fname, _download_cb)
file_handle.close()
return savePathDir +'/' + fname
Here is my first attempt at matching. I am returning the path just for compatibilities sake for now. Later I will access the stored files properly through the model.
new_image = CameraImage(video_channel = videochannel,timestamp = file_timestamp)
file_handle = new_image.image.open()
nvcftp.retrbinary("RETR " + fname, _download_cb)
file_handle.close()
new_image.save()
return new_image.path()
Is this correct?
I am confused about what order I should deal with the file_handle and the ImageField “image”
You are missing
_download_cb, so I’m not using it.Refs The File Object of Django. Try