• General
  • My Apps
  • SDKs
  • Protocols
  • Structures
  • Methods
  • Errors
Log in Register Log out
  • General

  • My Apps

  • SDKs
    • C
    • Java
    • Javascript
    • Php
    • Swift

  • Protocols
    • HTTP JSON Protocol
      • Authentication
      • Single Connection
      • Uploading Files
    • Binary Protocol
      • Sending Binary Request
      • Sending Files
      • Receiving Binary Response
      • Receiving Files Data

  • Structures
    • Datetime
    • Event
    • File Descriptors
    • Filenames
    • Metadata
    • Share
    • Tree

  • Methods
    • Intro
      • Global Parameters
      • Authentication
    • General
      • getdigest
      • userinfo
      • supportedlanguages
      • setlanguage
      • feedback
      • currentserver
      • diff
      • getfilehistory
      • getip
      • getapiserver
    • Folder
      • createfolder
      • createfolderifnotexists
      • listfolder
      • renamefolder
      • deletefolder
      • deletefolderrecursive
      • copyfolder
    • File
      • uploadfile
      • uploadprogress
      • downloadfile
      • downloadfileasync
      • copyfile
      • checksumfile
      • deletefile
      • renamefile
      • stat
    • Auth
      • sendverificationemail
      • verifyemail
      • changepassword
      • lostpassword
      • resetpassword
      • register
      • invite
      • userinvites
      • logout
      • listtokens
      • deletetoken
      • sendchangemail
      • changemail
      • senddeactivatemail
      • deactivateuser
    • Streaming
      • getfilelink
      • getvideolink
      • getvideolinks
      • getaudiolink
      • gethlslink
      • gettextfile
    • Archiving
      • getzip
      • getziplink
      • savezip
      • extractarchive
      • extractarchiveprogress
      • savezipprogress
    • Sharing
      • sharefolder
      • listshares
      • sharerequestinfo
      • cancelsharerequest
      • acceptshare
      • declineshare
      • removeshare
      • changeshare
    • Public Links
      • getfilepublink
      • getfolderpublink
      • gettreepublink
      • showpublink
      • getpublinkdownload
      • copypubfile
      • listpublinks
      • listplshort
      • deletepublink
      • changepublink
      • getpubthumb
      • getpubthumblink
      • getpubthumbslinks
      • savepubthumb
      • getpubzip
      • getpubziplink
      • savepubzip
      • getpubvideolinks
      • getpubaudiolink
      • getpubtextfile
      • getcollectionpublink
    • Thumbnails
      • getthumblink
      • getthumbslinks
      • getthumb
      • savethumb
    • Upload Links
      • createuploadlink
      • listuploadlinks
      • deleteuploadlink
      • changeuploadlink
      • showuploadlink
      • uploadtolink
      • uploadlinkprogress
      • copytolink
    • Revisions
      • listrevisions
      • revertrevision
    • Fileops
      • file_open
      • file_write
      • file_pwrite
      • file_read
      • file_pread
      • file_pread_ifmod
      • file_checksum
      • file_size
      • file_truncate
      • file_seek
      • file_close
      • file_lock
    • Newsletter
      • newsletter_subscribe
      • newsletter_check
      • newsletter_verifyemail
      • newsletter_unsubscribe
      • newsletter_unsibscribemail
    • Trash
      • trash_list
      • trash_restorepath
      • trash_restore
      • trash_clear
    • Collection
      • collection_list
      • collection_details
      • collection_create
      • collection_rename
      • collection_delete
      • collection_linkfiles
      • collection_unlinkfiles
      • collection_move
    • OAuth 2.0
      • authorize
      • oauth2_token
    • Transfer
      • uploadtransfer
      • uploadtransferprogress

  • Errors

file_open

Name

file_open

Auth

yes

Description

Opens a file descriptor.

Output

On success returns fd file descriptor which can be used in successive operations. Also returns the fileid of the file (useful when creating file).

Required

ParameterDescription
flagsint which can be a combination of the file_open flags.

Optional

ParameterDescription
pathstring path to the file, for which the file descirptior is created.
fileidint id of the folder, for which the file descirptior is created.
folderidint id of the folder, in which new file is created and file descirptior is returned.
namestring name of the file, in which new file is created and file descirptior is returned.
The use of these parameters, depends on the flags are given. Please, see the details below.

Example

{
    result: 0,
    fd: 1,
    fileid: 3489
}

Errors

CodeDescription
1000Log in required.
1001No full path or name/folderid provided.
1004No fileid or path provided.
1006Please provide flags.
2000Log in failed.
2001Invalid file/folder name.
2002A component of parent directory does not exist.
2003Access denied. You do not have permissions to preform this operation.
2004File or folder alredy exists.
2008User is over quota.
2009File not found.
2010Invalid path.
4000Too many login tries from this IP address.
5000Internal error. Try again later.
5001Internal upload error.

Flags

CodeDescription
0x0002O_WRITE
0x0040O_CREAT
0x0080O_EXCL
0x0200O_TRUNC
0x0400O_APPEND

If O_CREAT is set, file_open will create the file. In this case full "path" or "folderid" and "name" MUST be provided for the new file. If the file already exists the old file will be open unless O_EXCL is set, in which case open will fail.

If O_CREAT is not set, than full "path" or "fileid" MUST be provided. The function will fail if the file does not exist.

O_TRUNC will truncate files when opening existing files.

Files opened with O_APPEND will always write to the end of file (unless you use pwrite). That is the only reliable method without race conditions for writing in the end of file when there are multiple writers.

You do not need to specify O_WRITE even if you intend to write to the file. However that will preform write access control and quota checking and you will get possible errors during open, not at the first write.

2014 © pCloud. Terms and Conditions. Privacy Policy. Intellectual Property.
© pCloud. Terms and Conditions. Privacy Policy. Intellectual Property.
Reset Password
Check your e-mail for further instructions.
Reset