![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@dbp-toolkit/file-handling
Advanced tools
You can install these components via npm:
npm i @dbp-toolkit/file-handling
After you have installed the file handling components via npm you can use this example to get a button that opens the file source dialog. After you have selected a file you will see it in your browser log, and the file sink dialog will open, so you are able to store the file again.
<button onclick="openFilePicker()">Open file picker</button>
<dbp-file-source lang="en"></dbp-file-source>
<dbp-file-sink lang="en"></dbp-file-sink>
<script>
const fileSource = document.querySelector("dbp-file-source");
const fileSink = document.querySelector("dbp-file-sink");
// Listen to the event from file source
fileSource.addEventListener("dbp-file-source-file-selected", (ev) => {
const file = ev.detail.file;
console.log("File selected: ", file)
// This will open the file sink dialog
fileSink.files = [file];
});
function openFilePicker() {
// This will open the file source dialog
fileSource.setAttribute("dialog-open", "");
}
</script>
<script type="module" src="node_modules/@dbp-toolkit/file-handling/dist/dbp-file-source.js"></script>
<script type="module" src="node_modules/@dbp-toolkit/file-handling/dist/dbp-file-sink.js"></script>
This web component allows the selection of local files via file dialog or drag and drop and to select and download files from a Nextcloud instance.
<dbp-file-source></dbp-file-source>
lang
(optional, default: de
): set to de
or en
for German or English
<dbp-file-source lang="de"></dbp-file-source>
allowed-mime-types
(optional): if set accepts only files matching mime types
<dbp-file-source allowed-mime-types='application/pdf'></dbp-file-source>
... PDFs only<dbp-file-source allowed-mime-types='image/*'></dbp-file-source>
... images (of all sub types) only<dbp-file-source allowed-mime-types='image/png,text/plain'></dbp-file-source>
... PNGs or TXTs only<dbp-file-source allowed-mime-types='*/*'></dbp-file-source>
... all file types (default)enabled-sources
(optional, default: local
): sets which sources are enabled
local
and nextcloud
<dbp-file-source enabled-sources="local,nextcloud"></dbp-file-source>
disabled
(optional): disable input control
<dbp-file-source disabled></dbp-file-source>
decompress-zip
(optional): decompress zip file and send the contained files (including files in folders)
<dbp-file-source decompress-zip></dbp-file-source>
allowed-mime-types
will also be checked for the files in the zip filenextcloud-auth-url
(optional): Nextcloud Auth Url to use with the Nextcloud file picker
<dbp-file-source nextcloud-auth-url="http://localhost:8081/index.php/apps/webapppassword"></dbp-file-source>
nextcloud-web-dav-url
also needs to be set for the Nextcloud file picker to be activenextcloud-web-dav-url
(optional): Nextcloud WebDav Url to use with the Nextcloud file picker
<dbp-file-source nextcloud-web-dav-url="http://localhost:8081/remote.php/dav/files"></dbp-file-source>
nextcloud-auth-url
also needs to be set for the Nextcloud file picker to be activedialog-open
(optional): if this attribute is set at runtime the dialog for selecting local or Nextcloud files will open
document.querySelector("dbp-file-source").setAttribute("dialog-open", "")
text
(optional): the text that is shown above the button to select files
<dbp-file-source text="Please select some files"></dbp-file-source>
button-label
(optional): the text that is shown on the button to select files
<dbp-file-source button-label="Select files"></dbp-file-source>
dbp-file-source-file-selected
This event is sent if a file was selected.
Payload: {'file': File}
where File is the binary file that was selected
This web component is able to receive files and present as them as ZIP file download or upload files to a Nextcloud instance.
<dbp-file-sink></dbp-file-sink>
lang
(optional, default: de
): set to de
or en
for German or English
<dbp-file-sink lang="de"></dbp-file-sink>
enabled-destinations
(optional, default: local
): sets which destination are enabled
local
and nextcloud
<dbp-file-sink enabled-destinations="local,nextcloud"></dbp-file-sink>
filename
(optional, default: files.zip
): sets a file name to use for downloading the zip file
<dbp-file-sink filename="signed-documents.zip"></dbp-file-sink>
nextcloud-auth-url
(optional): Nextcloud Auth Url to use with the Nextcloud file picker
<dbp-file-sink nextcloud-auth-url="http://localhost:8081/index.php/apps/webapppassword"></dbp-file-sink>
nextcloud-web-dav-url
also needs to be set for the Nextcloud file picker to be activenextcloud-web-dav-url
(optional): Nextcloud WebDav Url to use with the Nextcloud file picker
<dbp-file-sink nextcloud-web-dav-url="http://localhost:8081/remote.php/dav/files"></dbp-file-sink>
nextcloud-auth-url
also needs to be set for the Nextcloud file picker to be activetext
(optional): the text that is shown above the button to download the zip file
<dbp-file-sink text="Download files as ZIP-file"></dbp-file-sink>
button-label
(optional): the text that is shown on the button to download the zip file
<dbp-file-sink button-label="Download files"></dbp-file-sink>
files
: an array of File objects which should be downloaded in the dialog
document.querySelector("dbp-file-sink").files = [file]
where file
is your File object# get the source
git clone git@gitlab.tugraz.at:dbp/web-components/toolkit.git
cd toolkit/packages/file-handling
# install dependencies
yarn install
# constantly build dist/bundle.js and run a local web-server on port 8002
yarn run watch-local
# build local packages in dist directory
yarn run build
Jump to http://localhost:8002 and you should get a demo page.
To use the Nextcloud functionality you need a running Nextcloud server with the webapppassword Nextcloud app like this Nextcloud Development Environment.
FAQs
Unknown package
The npm package @dbp-toolkit/file-handling receives a total of 17 weekly downloads. As such, @dbp-toolkit/file-handling popularity was classified as not popular.
We found that @dbp-toolkit/file-handling demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.