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

Help/Advice for PCF for canvas app to upload large file #636

Open
krunal039 opened this issue Oct 18, 2024 · 0 comments
Open

Help/Advice for PCF for canvas app to upload large file #636

krunal039 opened this issue Oct 18, 2024 · 0 comments

Comments

@krunal039
Copy link

I’m using PnPJs to create a PCF control for uploading large files to SharePoint within a canvas app. The code below is working while editing the canvas app, along with the redirection URI : https://authoring.eu-il109.gateway.prod.island.powerapps.com/v3.24095.15.310953622/embed/

`
import { IInputs, IOutputs } from "./generated/ManifestTypes";
import type { MSALOptions } from "@pnp/msaljsclient";
import { spfi, SPBrowser } from "@pnp/sp";
import { MSAL, getMSAL } from "@pnp/msaljsclient";
import "@pnp/sp/webs";
import "@pnp/sp/lists";
import "@pnp/sp/site-users/web";

export class pcfspolargeupload implements ComponentFramework.StandardControl<IInputs, IOutputs> {

constructor()
{

}

public async init(context: ComponentFramework.Context, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container:HTMLDivElement): Promise
{
let _notifyOutputChanged: () => void
let _context: ComponentFramework.Context
let _spContext: any

const options: MSALOptions = {
configuration: {
auth: {
authority: "https://login.microsoftonline.com/[TenantID]/",
clientId: "[AppID]",
},
cache: {
claimsBasedCachingEnabled: true // in order to avoid network call to refresh a token every time claims are requested
}
},
authParams: {
forceRefresh: false,
scopes: ["https://tenant.sharepoint.com/.default"],
}
};

const sp = spfi("https://tenant.sharepoint.com/").using(SPBrowser(), MSAL(options));

const user = await sp.web.currentUser();

// For logout later on
const msalInstance = getMSAL();
const currentAccount = msalInstance.getActiveAccount();

const list = sp.web.lists.getByTitle("Documents");

// we can use this 'list' variable to run more queries on the list:
const r = await list.select("Id")();

// log the list Id to console
console.log(r.Id);

container.appendChild(document.createTextNode(r.Id));
}

public updateView(context: ComponentFramework.Context): void
{
}
public getOutputs(): IOutputs
{
return {};
}

public destroy(): void
{
}
}`

Question/Request
When I publish the app and access it, the redirection URI changes to: https://runtime-app.powerplatform.com/publishedapp/e/default-cc83b6ac-505f-4efc-a552-a2c7bfa6d7e3/preloadindex/V1. The popup doesn’t close, and I’m unsure what I’m doing wrong. What steps should I take to get PnPJs working with my AAD app to upload large files to SharePoint via PCF control in Canvas app?

Image

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

No branches or pull requests

1 participant