FileSize is 0 bytes when curling a file from a presigned url

Started by VGetsov, August 14, 2024, 12:11:11 PM

Previous topic - Next topic

VGetsov

Hey there, I have the following issue:

I curl a file from AWS S3 using a presigned url and then I pipe it to exiftool. However, the FileSize is usually 0 bytes, sometimes it's a bit more (e.g. 66 bytes) but it doesn't seem to be equal to the real size of the file. I ran the command with verbose mode and the Content-Length header shows the real size.

Below is my code, where {source} is a presigned url, {destination} is a presigned url to write to and {tagsArg} is used to add stuff to the Keywords field if needed.

I also tried the following command in the terminal by simply executing curl {source} | exiftool - but the FileSize is still wrong.

I'd really appreciate some help  :)

        const exif = spawn(
          `curl -s '${source}' | exiftool ${tagsArg} - | curl -X PUT -H "Content-Type: application/octet-stream" '${destination}' --upload-file -`,
          { shell: true },
        )

StarGeek

Since you are receiving the file from a pipe redirected from cURL, it might not be possible to get a file size. It would require cURL to get the file size from the header and pass that along. But I can't find any source that indicates that cURL will do this.

I do find some answers where you could use cURL to get the header for an URL and extract the file size (Content-Length header) from that. But I also know that not all servers will pass this value. You would see this when downloading a file through a browser, and it doesn't give a percentage showing how much of the file has been downloaded.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

StarGeek

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

VGetsov


Phil Harvey

What version of ExifTool were you using?

Version 12.87 and later should no longer report FileSize for pipes.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).