Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] FileUploader: processing of files before upload via interface #1623

Conversation

nzamani
Copy link
Contributor

@nzamani nzamani commented Aug 2, 2017

The sap.ui.unified.FileUploader is an amazing control. However, making reuse of the existing code in custom controls can sometimes only be implemented using private APIs of sap.ui.unified.FileUploader which is always a bad practice.

This change introduces the new interface sap.ui.unified.IUploadableBlobs and changes the sap.ui.unified.FileUploader control to use this interface when upload() is called. It makes it save to implement custom controls that extend sap.ui.unified.FileUploader in order to modify the files before they get uploaded. This comes in handy in many use cases such, i.e. creating zip files for the upload.

This changes introduces minimal changes to the upload() APIs by using Promises internally. Here, the interface API sap.ui.unified.IUploadableBlobs.getProcessedBlobsFromArray is used - a simple way to allow sub-controls to re-use the functionality in an "upgrade-save" way. The default implementation of the interface API does nothing but resolving the promise with the files received from the sap.ui.unified.FileUploader without changing them. This default implementation makes sure that the current behaviour is not changed.

@CLAassistant
Copy link

CLAassistant commented Aug 2, 2017

CLA assistant check
All committers have signed the CLA.

@nzamani
Copy link
Contributor Author

nzamani commented Aug 2, 2017

When this pull request gets merged I will

  1. publish a custom control for UI5Lab to show this feature in action (my code is already finalized)
  2. write a blog about it (text is already finalized)
  3. write another blog + another control explaining in detail how to make use of this feature

@nzamani nzamani closed this Aug 2, 2017
@nzamani nzamani reopened this Aug 2, 2017
@nzamani nzamani force-pushed the feature-fileuploader-modify-blobs-before-upload-interface branch from c9353e9 to e553dff Compare August 2, 2017 08:16
nzamani added a commit to nzamani/ui5-nabi-m that referenced this pull request Aug 2, 2017
This will work if the following pull request get merged: SAP/openui5#1623

Currently, the overridden upload() uses private APIs.  Once the pull request gets merged, the overridden upload() can be removed

For details see code.
nzamani added a commit to nzamani/ui5-nabi-m that referenced this pull request Aug 2, 2017
This will work if the following pull request get merged: SAP/openui5#1623

Currently, the overridden upload() uses private APIs.  Once the pull request gets merged, the overridden upload() can be removed

For details see code.
@nzamani nzamani force-pushed the feature-fileuploader-modify-blobs-before-upload-interface branch from e553dff to 89b0008 Compare August 6, 2017 09:51
@nzamani nzamani force-pushed the feature-fileuploader-modify-blobs-before-upload-interface branch 2 times, most recently from 555c1d6 to 725ac2c Compare August 17, 2017 07:27
@stephania87
Copy link

Hi @nzamani,

Thank you for your pull request. We created an internal record 1770315265 to check the suggested changes.
We will post an update about the status of the issue in this thread, in GitHub.

Regards,
Stefania

…nterface

This change introduces the new interface sap.ui.unified.IProcessableBlobs and changes the sap.ui.unified.FileUploader control to use this interface when upload() is called. It makes it save to implement custom controls that extend sap.ui.unified.FileUploader an which mobify the Files before they get uploaded. This comes in handy in use cases such as creating zip file for the upload. Internally Promises are used.
@nzamani nzamani force-pushed the feature-fileuploader-modify-blobs-before-upload-interface branch from 725ac2c to bdee22f Compare September 15, 2017 07:54
@myordanov
Copy link
Contributor

Hi Colleagues,
the request is merged with commit 6d4bce0

Regards, Mihail.

@myordanov myordanov closed this Sep 21, 2017
nzamani added a commit to nzamani/ui5-nabi-m that referenced this pull request Sep 21, 2017
…y fallback

Pull Request SAP/openui5#1623 is merged. This means we can now use the introduced interface ap.ui.unified.IProcessableBlobs in order to be "API safe".
matz3 referenced this pull request Sep 22, 2017
…ad using interface

This change introduces the new interface sap.ui.unified.IProcessableBlobs and changes the sap.ui.unified.FileUploader control to use this interface when upload() is called.
It makes it safe to implement custom controls that extend sap.ui.unified.FileUploader and which modify the Files before they get uploaded.
This comes in handy in use cases such as creating zip file for the upload.
Internally Promises are used.

Change-Id: I5ff85b6da716d400826ee1f1f544f05d0e821706
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants