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
MediaBaseobject.Parameters: Variables: inputFileField – Name of the model field where the file will be stored.
Return type: MediaBasesubclass.
-
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
EncodingProfilenames, e.g.[u"MP4", u"WebM Audio/Video"] - extension (str) – The extension to use for the temporary filename.
Defaults to
media.
-
save(fileData)¶ Save
fileDatain temporary file and start encoding.Parameters: fileData ( io.BytesIO) – The media bytes.Return type: MediaBaseReturns: A new instance of type self.model.
- prefix (str) – The prefix to use for the temporary filename, e.g.