Skip to content

Instantly share code, notes, and snippets.

@addy
Last active March 21, 2023 14:41
Show Gist options
  • Save addy/2f1723e51724cf0ca05f0f5eae6e86a4 to your computer and use it in GitHub Desktop.
Save addy/2f1723e51724cf0ca05f0f5eae6e86a4 to your computer and use it in GitHub Desktop.
newSamplePart.ts
const getIdentity = async () =>
await ArcGISIdentityManager.signIn({
username,
password,
});
const auth = await getIdentity();
const file = fs.readFileSync('./test.geojson');
const fileBlob = new Blob([new Uint8Array(file).buffer], {
type: 'application/geo+json',
});
const item: ICreateItemResponse = await createItem({
item: {
title: 'Hello World',
type: 'GeoJson',
},
authentication: auth,
multipart: true,
filename: 'test.geojson',
async: true,
overwrite: true,
});
// Note: You can add params: { f: 'text' } to see the HTML response
const part = await addItemPart({
id: item.id,
file: fileBlob,
partNum: 1,
authentication: auth,
});
const commit = await commitItemUpload({
item: { title: 'Hello World', type: 'GeoJson' },
id: part.id,
authentication: auth,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment