Sharedsupport / 2015-10-25-103848-file-raw.sagewsOpen in CoCalc

Examples for support purposes...

File: /projects/4a5f0542-5873-4eed-a85c-a18c706e8bcd/.sagemathcloud/
Signature : smc.file(self, filename, show=True, done=False, download=False, once=False, events=None, raw=False)
Docstring :
Display or provide a link to the given file.  Raises a RuntimeError
if this is not possible, e.g, if the file is too large.

If show=True (the default), the browser will show the file, or
provide a clickable link to it if there is no way to show it.

If show=False, this function returns an object T such that T.url
(or str(t)) is a string of the form "/blobs/filename?uuid=the_uuid"
that can be used to access the file even if the file is immediately
deleted after calling this function (the file is stored in a
database). Also, T.ttl is the time to live (in seconds) of the
object.  A ttl of 0 means the object is permanently available.

raw=False (the default):
   If you use the URL

   then the server will include a header that tells the browser to
   download the file to disk instead of displaying it.  Only
   relatively small files can be made available this way.  However,
   they remain available (for a day) even *after* the file is
   deleted. NOTE: It is safe to delete the file immediately after
   this function (salvus.file) returns.

   Instead, the URL is to the raw file, which is served directly
   from the project:


   This will only work if the file is not deleted; however,
   arbitrarily large files can be streamed this way.

This function creates an output message {file:...}; if the user
saves a worksheet containing this message, then any referenced
blobs are made permanent in the database.

The uuid is based on the Sha-1 hash of the file content (it is
computed using the function sage_server.uuidsha1).  Any two files
with the same content have the same Sha1 hash.