Since Export data collection is not available using WIX JS, I would like to create or update a document (csv preferable, but it can be txt or json), which is stored into a data collection and then upload it to Dropbox.
Is there an available syntax by which I can prepare such data and store it into a document stored in a WIX data collection?
The data itself I would like to upload is also in a data collection. So, I can save the relevant array query result in a collection field of array type.
Alternatively, is there a possibility to upload this array directly to Dropbox using Dropbox npm. I installed this npm and managed to activate if for some functions already. But, I’m stacked because I have no idea where the file I want to upload should be written in the Dropbox API (contents parameter). Maybe it could be the WIX URL?
I resolved by myself as follows: I installed dropbox as someone suggested and wrote the following JSW code in backend.
import dropbox from ‘dropbox’ ;
import { fetch } from ‘wix-fetch’ ;
const access = ‘My Access dropbox token for API from application’
var content = I trasnfered the contents from the client
export function addfiletodropbox(contents) {
let Dropbox = dropbox.Dropbox;
let dbx = new Dropbox({ accessToken: access, fetch: fetch });
return new Promise( function (resolve, reject) {
resolve(
dbx.filesUpload( { “path”: “/hachnasot.csv” , contents })
.then((response) => {
**return** response;
})
. **catch** ((error) => {
**return** error;
})
);
});
}
In the Client side I wrote the following:
import { addfiletodropbox } from ‘backend/dropboxjsw’ ;
var BOM = “\uFEFF” //This was added to fix utf-8 hebrew chars.
var hebf = “”
async function addfiles(contents) {
i = 0
do {
hebf = BOM + String(achnasot[i].shemesek)
//console.log(“contents==>”, contents)
contents = contents + hebf + “,” + achnasot[i].dira + “,” + achnasot[i].misparkabala + “,” + achnasot[i].shuratkabala + “,” +
i += 1
let response = await addfiletodropbox(contents);
console.log( “response===>” , response)
}
} while (i <= q)
In the client I added a button to activate the above async function " addfiles"
Good luck to all.