Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Files#5701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kearfy merged 93 commits intomainfrommicha/files
Apr 11, 2025
Merged

Files#5701

kearfy merged 93 commits intomainfrommicha/files
Apr 11, 2025

Conversation

kearfy
Copy link
Member

@kearfykearfy commentedMar 24, 2025
edited
Loading

Thank you for submitting this pull request. We really appreciate you spending the time to work on SurrealDB. 🚀 🎉

What is the motivation?

See#1652. Files are a big part of data, and it's something we'd like to offer with a certain capacity in SurrealDB. This PR aims to be a first start in building an ecosystem of tools around files, whilst also building the foundation of features to come in the future.

What does this change do?

This PR adds a couple new features and changes regarding file support:

  • Allows you to define a "Global Bucket".
  • Allows you to define a database-level bucket, using either the global bucket, or specifying a custom "backend", such as in-memory or a file system backed bucket.
  • Introduces File pointers, to interact with files stored inside a bucket:
    • f"bucket:/some/key/to/a/file.txt"
    • f"bucket:/some/key/with\ escaped"
    • f"bucket:/some/key".put(b"00aa")
    • f"bucket:/some/key".get()
    • The file pointer is also introduced in the JS scripting functions as aFile class (which takes a bucket name and key inside the constructor method). It also implements a.key() and.bucket() method on the class, and can be passed to the file functions as an argument.
  • Introduces byte strings. The current way of interacting with bytes value, and how they are represented, is confusing and a lot of conversions between bytes and other value types are missing.
    • b"0099aaff" - A "b" prefixed string, similar to UUIDs and Datetimes, allows you to create a<bytes> value using a HEX string.
    • Bytes are also formatted this way
    • Conversions between strings <-> bytes, and between arrays <-> bytes are all implemented now.
  • Introduces functions to work with file pointers:
    • file::bucket(file)

      • Returns:string
      • Idiom:<file>.bucket()
    • file::key(file) -> string

      • Returns:string
      • Idiom:<file>.key()
    • file::list(T (string), option<ListOptions>)

      • ListOptions:{ prefix: option<string>, start: option<string>, limit: option<int> }
      • Returns:array<{ size: int, file: file<T>, updated: datetime }>
    • file::put(file, string | bytes)

      • Idiom:<file>.put(string | bytes)
    • file::put_if_not_exists(file, string | bytes)

      • Idiom:<file>.put_if_not_exists(string | bytes)
    • file::get(file)

      • Returns:bytes
      • Idiom:<file>.get()
    • file::head(file<T>)

      • Returns:{ size: int, file: file<T>, updated: datetime }
      • Idiom:<file<T>>.head()
    • file::exists(file)

      • Returns:bool
      • Idiom:<file>.exists()
    • file::delete(file)

      • Idiom:<file>.delete()
    • file::copy(file, string)

      • Idiom:<file>.copy(string)
    • file::copy_if_not_exists(file, string)

      • Idiom:<file>.copy_if_not_exists(string)
    • file::rename(file, string)

      • Idiom:<file>.rename(string)
    • file::rename_if_not_exists(file, string)

      • Idiom:<file>.rename_if_not_exists(string)
  • Additional functions:
    • type::file(T (string), string) (bucket, key)
      • Returns:file<T>
    • type::string_lossy(bytes)
      • Returns:string

Security

  • For local file backends, every folder which you want to point a file bucket to, needs to be allow-listed in theSURREAL_FILE_ALLOWLIST environment variable. The file backend implementation considers any nested path listed within that environment variable to be allowed.
  • TheSURREAL_FILE_ALLOWLIST option now no longer filters out folders which do not yet exist. Instead, it is up to the implementation which uses this list to do that. The function already used to check if a path is allowed already does canonalization, so existing implementation are still secure.

What is your testing strategy?

Added tests for basic file operations. Further tests to be added in a next PR

Is this related to any issues?

Does this change need documentation?

  • Needs documentation

https://github.com/surrealdb/docs.surrealdb.com/tree/files

Have you read the Contributing Guidelines?

DariusCorvus reacted with hooray emojiDariusCorvus reacted with heart emojicabaucom376, ThatOneCalculator, charlescgs, Dhghomon, Ekwuno, AlbertMarashi, lkwr, LucyEgan, and DariusCorvus reacted with rocket emoji
@kearfykearfy added this pull request to themerge queueApr 11, 2025
Merged via the queue intomain with commitc9140a0Apr 11, 2025
34 of 36 checks passed
@kearfykearfy deleted the micha/files branchApril 11, 2025 14:19
@rushmoremrushmorem added this to thev3.0.0-alpha.1 milestoneApr 15, 2025
@kearfykearfy mentioned this pull requestApr 25, 2025
3 tasks
@DhghomonDhghomon mentioned this pull requestMay 1, 2025
2 tasks
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@DelSkaynDelSkaynDelSkayn left review comments

@emmanuel-kelleremmanuel-kelleremmanuel-keller approved these changes

@tobiemhtobiemhAwaiting requested review from tobiemhtobiemh is a code owner

Assignees
No one assigned
Labels
topic:securityThis is related to security
Projects
None yet
Milestone
v3.0.0-alpha.1
Development

Successfully merging this pull request may close these issues.

Feature: Support for storing large binary data / files
6 participants
@kearfy@lkwr@emmanuel-keller@DelSkayn@rushmorem@Dhghomon

[8]ページ先頭

©2009-2025 Movatter.jp