Tar File Creation

Torteski
Posts: 2
Joined: Tue Aug 20, 2019 12:37 pm

Tar File Creation

Postby Torteski » Tue Aug 20, 2019 12:51 pm

Hello all,

I am looking for a solution for the following:
- use a ESP CAM board to take pictures and store them in a SD card
- archive the images in a single file (daily/weekly/monthly)
- Serve a webpage with download links to the archives.
The taking pictures and serving wepbages part is simple enough, there are many samples avalable.
But i cannot find anything for archiving. And my coding skills are not that advanced to start from scratch.
The ideal solution would be having montly packages of about 100MB worth of images.

Can anyone give me some pointers on this? is this possible or practical on the ESP32?

Thank you

vonnieda
Posts: 145
Joined: Tue Nov 07, 2017 3:42 pm

Re: Tar File Creation

Postby vonnieda » Tue Aug 20, 2019 2:35 pm

I use microtar ( https://github.com/rxi/microtar ) for something similar. Seems to work pretty well.

Jason

Torteski
Posts: 2
Joined: Tue Aug 20, 2019 12:37 pm

Re: Tar File Creation

Postby Torteski » Tue Aug 20, 2019 5:10 pm

Hi Jason,

Thank you very much for the quick reply. I would just like to bother you a few minutes more.

I am trying to use it with Arduino and the code compiles file:
  1.   camera_fb_t * fb = NULL;
  2.  
  3.   // Take Picture with Camera
  4.   fb = esp_camera_fb_get();  
  5.  
  6. mtar_t tar;
  7.  
  8. mtar_open(&tar, "test.tar", "w");
  9.  
  10. mtar_write_file_header(&tar, "test.jpg", fb->len);
  11. mtar_write_data(&tar, fb->buf, fb->len);
  12.  
  13. mtar_finalize(&tar);
  14.  
  15. mtar_close(&tar);
  16.  
but i don't know how to write the archive to the sd card
from the ESP32 CAM sd card example i have:
  1.   File file = fs.open(path.c_str(), FILE_WRITE);
  2.   if(!file){
  3.     Serial.println("Failed to open file in writing mode");
  4.   }
  5.   else {
  6.     file.write(fb->buf, fb->len); // payload (image), payload length
  7.     Serial.printf("Saved file to path: %s\n", path.c_str());
  8.   }
  9.   file.close();
that saves the img to the sd card, how can i adapt this to save the tar file instead.

Also does this library rewrite the tar file every time we add a new file?

Thank you

Who is online

Users browsing this forum: No registered users and 73 guests