This service can be used to control the uploading of content as well as the updating the content of existing nodes on an Alfresco Repository.
- Since:
- 1.0.52
- Copyright:
- Copyright (C) 2005-2020 Alfresco Software Limited
- License:
- GNU Lesser General Public License, see: Open Source Licensing
- Source:
Members
-
_numUploadsInProgress :number
-
An internal counter for the currently uploading files.
Type:
- number
- Default Value:
- 0
- Source:
-
apiVersion :number
-
The Alfresco repository features multiple upload REST APIs. Up to and including version 5.1 of Alfresco supports the "version zero" REST API (also known as Share Services API) for Upload. In addition post 5.1 there is a "version one" Public Upload API also. Set this value to 1 to use the new version one API, else the classic v0 API will be used and Share Services AMP must be applied to the repository.
Type:
- number
- Since:
- 1.0.55
- Default Value:
- 0
- Source:
-
fileStore :object
-
Stores references and state for each file that is in the file list. The fileId is used as the key and the value is a File object.
Type:
- object
- Default Value:
- null
- Source:
-
i18nRequirements :object[]
-
An array of the i18n files to use with this widget.
Type:
- object[]
- Default Value:
- [{i18nFile: "./i18n/_BaseUploadService.properties"}]
- Source:
-
maxSimultaneousUploads :number
-
The maximum quantity of simultaneous uploads.
Type:
- number
- Default Value:
- 1
- Source:
-
STATE_ADDED :number
-
File(s) is been added
Type:
- number
- Default Value:
- 2
- Source:
-
STATE_BROWSING :number
-
The user is browsing and adding files to the file list
Type:
- number
- Default Value:
- 1
- Source:
-
STATE_FAILURE :number
-
File failed to upload.
Type:
- number
- Default Value:
- 5
- Source:
-
STATE_FINISHED :number
-
All files are processed and have either failed or been successfully uploaded to the server.
Type:
- number
- Default Value:
- 4
- Source:
-
STATE_SUCCESS :number
-
File was successfully STATE_SUCCESS.
Type:
- number
- Default Value:
- 6
- Source:
-
STATE_UPLOADING :number
-
File(s) is being uploaded to the server
Type:
- number
- Default Value:
- 3
- Source:
-
totalNewUploads :number
-
This state-variable is used to track the current overall progress, and is equal to the number of "in progress" uploads. This is incremented by the number of files in an upload-request, and reset once all of the files have either been uploaded or failed to upload.
Type:
- number
- Default Value:
- 0
- Source:
-
uploadDisplayWidget :object
-
The widget that displays the uploads' progress.
Type:
- object
- Default Value:
- null
- Source:
-
uploadsContainerTitle :string
-
This is the default title for the uploads container.
Type:
- string
- Default Value:
- "uploads-container.title"
- Source:
-
uploadsContainerTitleComplete :string
-
This is the default title for the uploads container.
Type:
- string
- Default Value:
- "uploads-container.title-complete"
- Source:
-
uploadsContainerTitleUpdateTopic :string
-
This is the topic on which to publish updates to the title container.
Type:
- string
- Default Value:
- null
- Source:
-
uploadTopic :string
-
The topic that this service will listen to, to initiate a file upload.
Type:
- string
- Source:
-
uploadURL :string
-
The location of the upload endpoint, used when using an apiVersion of 0.
Type:
- string
- Since:
- 1.0.55
- Default Value:
- "api/upload"
- Source:
-
widgetsForUploadDisplay :object[]
-
The widget definition that displays the uploads' progress. This should be a single widget that implements the interface defined by _UploadsDisplayMixin.
Type:
- object[]
- Default Value:
- null
- Source:
Methods
-
addInvalidFile(file)
-
Notifies the uploads-display widget that a file could not be uploaded.
Parameters:
Name Type Description file
object The invalid file - Source:
-
cancelListener(fileId, evt)
-
Handle cancelled upload requests.
Parameters:
Name Type Description fileId
string The unique id of the file being uploaded evt
object The cancellation event - Source:
-
constructUploadData(file, fileName, targetData)
-
Constructs the upload payload object to be added to the fileStore object for each file. The object constructed is designed to work with the Alfresco REST service for uploading documents. This function can be overridden to support different APIs
Parameters:
Name Type Description file
object The file being uploaded fileName
object The name of the file being uploaded targetData
object Information about where and how to upload the data - Source:
-
failureListener(fileId, evt)
-
Handle an error occurring during the upload.
Parameters:
Name Type Description fileId
string The unique id of the file being uploaded evt
object The failure event - Source:
-
initService()
-
If a service needs to act upon its post-mixed-in state before registering subscriptions then this is where it should be done. It is comparable to postMixInProperties in a widget in the class lifecycle.
- Source:
-
onUploadCancelRequest(payload)
-
Cancel the specified upload.
Parameters:
Name Type Description payload
object The publication payload - Since:
- 1.0.56
- Source:
-
onUploadFinished(fileId)
-
Handler that's called after an upload has finished (in any state)
Parameters:
Name Type Description fileId
string The unique id of the file being uploaded - Source:
-
onUploadRequest(payload)
-
The main handler for an upload request.
Parameters:
Name Type Description payload
object The publication payload - Source:
-
onUploadsBatchComplete(payload)
-
This listener will be called each time a batch of uploads (grouped by upload request) completes.
Parameters:
Name Type Description payload
object The payload containing the original upload request - Source:
-
onUploadsContainerClosed()
-
Handles the closing of the uploads container.
- Source:
-
processUploadCompletion(fileId, evt)
-
Called when an upload "load" event fires. This merely means that the server has responded though, so it could still be an error.
Parameters:
Name Type Description fileId
object The unique identifier of the file evt
object The completion event - Source:
-
processUploadFailure(fileId, evt)
-
Called if a request fails or completes with a non-success status code.
Parameters:
Name Type Description fileId
object The unique identifier of the file evt
object The completion event - Source:
-
processWidgetsForUploadDisplay() → {object[]}
-
This function can be called when creating the upload display. It ensures that the root widget is correctly configured to be assigned to the widgetsForUploadDisplay reference. Care should be taken When overriding the showUploadsWidget to ensure that any model is correctly setup by calling this function.
- Source:
Returns:
The object model for rendering the upload display- Type
- object[]
-
registerSubscriptions()
-
Register this service's subscriptions.
- Source:
Listens to Events:
-
reset()
-
Reset the state of the service.
NOTE: This does not cancel any in-progress uploads.
- Source:
-
resetTotalUploads()
-
This function is called when all uploads have completed and resets the totalNewUploads counter to zero.
- Since:
- 1.0.54
- Support:
-
- This function is safe to be overridden by extending or mixing modules (at least until the next major release). The inherited code must be called in the overriding function and if the inherited function returns a value then that value must be returned by the overriding function.
- Source:
-
showUploadsWidget() → {object}
-
Ensure the uploads display widget is available
- Source:
Returns:
A promise, that will resolve when the widget is ready to accept upload information.- Type
- object
-
spawnFileUploads()
-
Check to see whether there are any waiting uploads that can be started (up to the maxSimultaneousUploads).
- Source:
-
startFileUpload(Contains)
-
Starts the actual upload for a file
Parameters:
Name Type Description Contains
object info about the file and its request. - Source:
-
startFileUploads(filesToUpload, targetData)
-
Create the file-upload requests.
Parameters:
Name Type Description filesToUpload
object[] The files to be uploaded targetData
object The data that identifies where to upload the files to. - Source:
-
successListener(fileId, evt)
-
Handler for the upload request completing.
Parameters:
Name Type Description fileId
string The unique id of the file being uploaded evt
object The success event - Source:
-
updateAggregateProgress()
-
Calculates the overall progress of all the uploads and calls the display widget with the data.
- Source:
-
uploadProgressListener(fileId, evt)
-
This function listens for upload progress events retured from the XMLHttpRequest object and adjusts the display to give a visual indication of how the upload for the related file is progressing.
Parameters:
Name Type Description fileId
string The unique id of the file being uploaded evt
object See ProgressEvent on MDN - Source:
-
validateFile(file)
-
Validate a single file, throwing an exception if it fails.
Parameters:
Name Type Description file
object The file - Source:
-
validateFiles(files) → {object[]}
-
Validate the supplied collection of files, sending a notification of any invalid ones, and returning the valid ones.
Parameters:
Name Type Description files
object[] The files - Source:
Returns:
The valid files- Type
- object[]