unlinkAsync.md

September 24, 2025 ยท View on GitHub

unlinkAsync [Server]

Unlink file an its subversions from FS.

FilesCollection#unlinkAsync(fileRef: FileObj, version?: string): Promise<FilesCollection>

Warning

This is low-level method. You shouldn't use it, unless you know what you're doing.

  • fileRef {object} - Full fileRef object, returned from (await FilesCollection.findOneAsync()).get()
  • version {string} - [Optional] If specified, only subversion will be unlinked
  • Returns {promise} - Current FilesCollection instance
import { FilesCollection } from 'meteor/ostrio:files';

const imagesCollection = new FilesCollection({collectionName: 'images'});
await imagesCollection.unlinkAsync(await Images.collection.findOneAsync({}));
// Unlink a version of the file:
await imagesCollection.unlinkAsync(await Images.collection.findOneAsync({}), 'thumbnail');