CURLOPT_NEW_FILE_PERMS(3)

πŸ’… CURLOPT_NEW_FILE_PERMS ✨

bestie, literally welcome to the CURLOPT_NEW_FILE_PERMS page, straight out of the Library Functions Manual πŸŽ€ ok so pull up a chair, we're talking permissions today and it's gonna be iconic.


🌸 NAME 🌸

CURLOPT_NEW_FILE_PERMS β€” the permissions for files you create remotely, no cap πŸ”₯


✨ SYNOPSIS ✨

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NEW_FILE_PERMS,
                          long mode);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so you pass a long as the parameter, and that value is literally the permissions that get set on newly created files on the remote server. that's it, that's the whole vibe πŸ’…

the default value is 0644, which is giving sensible-and-chill.

the only protocols that can use this are sftp://, scp://, and file:// β€” everyone else can sit this one out, iykyk πŸ™ˆ


πŸŽ€ DEFAULT πŸŽ€

0644


🌈 PROTOCOLS 🌈

this functionality affects file, scp and sftp 🫢


πŸ“ EXAMPLE πŸ“

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    curl_easy_setopt(curl, CURLOPT_URL, "sftp://upload.example.com/file.txt");
    curl_easy_setopt(curl, CURLOPT_NEW_FILE_PERMS, 0664L);
    result = curl_easy_perform(curl);
  }
}

look at her go 😭✨ setting 0664L before the upload, main character energy fr fr.


⭐ AVAILABILITY ⭐

added in curl 7.16.4 β€” vintage but still slaying πŸ‘‘


πŸ’œ RETURN VALUE πŸ’œ

curl_easy_setopt(3) returns a CURLcode indicating success or error.

CURLE_OK (0) means everything was OK πŸ₯³ β€” and non-zero means an error occurred, so go check libcurl-errors(3) to find out what went wrong πŸ’€


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page bestie, go forth and chmod your remote uploads πŸ’–

this has been libcurl, dated 2026-10-12 β€” CURLOPT_NEW_FILE_PERMS(3), signing off πŸ§šβœ¨πŸ¦‹

πŸ“¦ where this page comes from