2

Hi I have an image in my memory and I want to sent it through an external FTP library.

This FTP library accepts only and only standard C FILE and the sample codes provided by this library reads data only from hard disk. In my application I don't want to store my images in the hard disk and then read them using FILE variable, instead I want to do the conversion in my memory so it's faster and more professional.

My image is in the form of uchar * but I can change it to std::String or QByteArray or any other type of string. Now I want to know how can I have a file which is filled by my image data so I will get rid of storing it into the hard disk and read it again.

My pseudo code:

   uchar * image = readImage();
   FILE * New_Image = String2FileConverter(image); //I need this function
   FTP_Upload(New_Image);
Dimitry
  • 81
  • 7

1 Answers1

5

On Posix systems, you can use fmemopen to create a memory-backed file handle.

Kerrek SB
  • 464,522
  • 92
  • 875
  • 1,084
  • Here's the analogous [question for Windows](http://stackoverflow.com/questions/12249610/c-create-file-in-memory). – Kerrek SB Jun 29 '14 at 12:05