Utilities¶
Utilities.
-
get_random_filename
(file_extension=u'png', length=12)¶ Returns a random filename with an optional length and file-extension.
Parameters: Return type: Returns: A random filename, e.g.
4AwV8Ckn65a3.png
.
-
get_media_upload_to
(instance, filename)¶ Get target path for user file uploads.
Parameters: - instance (
django.db.models.Model
) – Model instance. - filename (str) – The filename for the file being uploaded, eg. ‘test.png’.
Return type: - instance (
-
parseMedia
(data)¶ Decode base64-encoded media data and return result.
Parameters: data (str) – base64-encoded string Return type: str
-
storeMedia
(model, inputFileField, title, profiles, fpath)¶ Encode and store
MediaBase
object.Parameters: Variables: inputFileField – Name of the model field where the file will be stored.
Return type: MediaBase
subclass.
-
class
TemporaryMediaFile
(prefix, model, inputFileField, profiles, extension=u'media')¶ Container to store a temporary media file for encoding.
Parameters: - prefix (str) – The prefix to use for the temporary filename, e.g.
video_
. - model (
django.db.models.Model
) – The model to store the file on, e.g. a subclass ofMediaBase
. - inputFileField (str) – Name of the model field where the file will be stored.
- profiles (list) – List of
EncodingProfile
names, e.g.[u"MP4", u"WebM Audio/Video"]
- extension (str) – The extension to use for the temporary filename.
Defaults to
media
.
-
save
(fileData)¶ Save
fileData
in temporary file and start encoding.Parameters: fileData ( io.BytesIO
) – The media bytes.Return type: MediaBase
Returns: A new instance of type self.model
.
- prefix (str) – The prefix to use for the temporary filename, e.g.