Media
Manage the media of your online spreadsheets using the following methods.
Documentation
Section titled “Documentation”Methods
Section titled “Methods”Available methods for worksheet media management.
| Method | Description |
|---|---|
| setMedia | Set the properties of one or more media. @param media[].id - media guid. @param media[].src - media src used in floating images. Jworksheet setMedia(media: { id?: string; src?: string; [key: string]: any; }[]): Promise<void> POST /api/:guid/:worksheetIndex/media |
| deleteMedia | Remove one or more media. @param ids - media identifiers. Jworksheet deleteMedia(ids: string[]): Promise<void> POST /api/:guid/:worksheetIndex/media |
Examples
Section titled “Examples”Add media
Section titled “Add media”Add floating image.
import { Client } from "@intrasheets/client";
// Create a new clientconst client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",});
// Spreadsheet Guidconst guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instanceconst spreadsheet = client.getSpreadsheet(guid);
// Get Jworksheet objectconst worksheet = spreadsheet.getWorksheet(0);
// New mediaconst media = [ { id: "1e2d0a59-827d-48dc-b86c-cf30bd7c5ea4", src: "https://lemonadejs.com/templates/default/img/components.svg", left: 100, top: 150, width: 200, height: 150, },];
// Add floating imageworksheet .setMedia(media) .then(() => { // It worked correctly }) .catch((err) => { console.log(err); });curl -X POST "http://localhost:8009/api/79b45919-c751-4e2b-a49a-6c1286e2fc03/0/media" \ -H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i" \ -H "Content-Type: application/json" \ -d '{ "media": [ { "id": "1e2d0a59-827d-48dc-b86c-cf30bd7c5ea4", "src": "https://lemonadejs.com/templates/default/img/components.svg", "left": 100, "top": 150, "width": 200, "height": 150 } ] }'Delete media
Section titled “Delete media”import { Client } from "@intrasheets/client";
// Create a new clientconst client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",});
// Spreadsheet Guidconst guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instanceconst spreadsheet = client.getSpreadsheet(guid);
// Get Jworksheet objectconst worksheet = spreadsheet.getWorksheet(0);
// Remove floating imageworksheet .deleteMedia(["1e2d0a59-827d-48dc-b86c-cf30bd7c5ea4"]) .then(() => { // It worked correctly }) .catch((err) => { console.log(err); });curl -X DELETE "http://localhost:8009/api/79b45919-c751-4e2b-a49a-6c1286e2fc03/0/media" \ -H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i" \ -H "Content-Type: application/json" \ -d '{ "ids": ["1e2d0a59-827d-48dc-b86c-cf30bd7c5ea4"] }'