How does ossfs upload a local file?

Updated at:

If you are confused about how ossfs uploads a local file, you can refer to this topic to be familiar with the mechanism and process of ossfs file upload in details.

Workflow

  1. Create or open a local file: Create a local file by calling the POSIX create operation or open an existing file by calling the POSIX open operation. In this case, ossfs creates a cache file on the local disk.

  2. Write data to the cache file: Continuously write data to the cache file on the local disk by calling the POSIX write operation.

  3. Upload the cache file to OSS: Close the cache file by calling the POSIX close operation and upload the cache file to the bucket by calling an OSS API operation.

The following table describes the differences between creating and closing the cache file in the default mode and cache mode

Operation

Default mode

Cache mode

Create a local file

Create a temporary local file invisible to the user in the temporary directory as a cache file. The default temporary directory is /tmp. You can specify a custom temporary directory by specifying the -otmpdir parameter.

Specify the -ouse_cache parameter to create a local file that has the same name as the value of the parameter in the cache directory as the cache file.

Close a local file

The temporary local file in the temporary directory is deleted.

By default, the cache file in the cache directory is not deleted. If the local cache space is insufficient, the cache file is deleted.

How ossfs works

image

References

  • If you write data to the local file after the file is created, you cannot view the data in the bucket.

    Files are uploaded in a centralized manner only when the files are closed. You cannot view the files when you write data to the files.

  • Method to resolve the error that the system disk has no available space:

    By default, data is written to the /tmp directory in the system disk. You can specify another directory by specifying the -otmpdir parameter. For more information, see Data cache.