Overview
The Flash Transfer API (NTQQFlashApi) provides methods for creating and managing flash file transfers. Flash transfers allow temporary file sharing with automatic expiration.
Flash transfers are temporary and files expire after a set period. They’re ideal for quick file sharing without permanent storage.
API Reference
createFlashTransferUploadTask
Create a flash transfer upload task for sharing files.
Array of file paths to upload
Path to thumbnail image (optional)
Unique identifier for the created fileset
Example:
const fileSetId = await core . apis . FlashApi . createFlashTransferUploadTask (
[ '/path/to/file1.pdf' , '/path/to/file2.jpg' ],
'/path/to/thumbnail.jpg' ,
'Project Documents'
);
console . log ( 'Flash transfer created:' , fileSetId );
downloadFileSetBySetId
Download a complete fileset by its ID.
Local path where files were downloaded
Example:
const downloadPath = await core . apis . FlashApi . downloadFileSetBySetId ( 'fs_abc123' );
console . log ( 'Files downloaded to:' , downloadPath );
getShareLinkBySetId
Generate a shareable link for a fileset.
URL for sharing the fileset
Access code for the share link
Example:
const { shareLink , shareCode } = await core . apis . FlashApi . getShareLinkBySetId ( 'fs_abc123' );
console . log ( `Share link: ${ shareLink } ` );
console . log ( `Access code: ${ shareCode } ` );
fromShareLinkFindSetId
Get fileset ID from a share link.
Example:
const fileSetId = await core . apis . FlashApi . fromShareLinkFindSetId ( 'abc123xyz' );
console . log ( 'Fileset ID:' , fileSetId );
getFileListBySetId
Get list of files in a fileset.
Example:
const files = await core . apis . FlashApi . getFileListBySetId ( 'fs_abc123' );
files . forEach ( file => {
console . log ( ` ${ file . fileName } ( ${ file . fileSize } bytes)` );
});
getFileSetInfoBySetId
Get detailed information about a fileset.
Fileset information Number of files in the set
Example:
const info = await core . apis . FlashApi . getFileSetInfoBySetId ( 'fs_abc123' );
console . log ( `Fileset: ${ info . filesetName } ` );
console . log ( `Files: ${ info . fileCount } ` );
console . log ( `Expires: ${ new Date ( info . expireTime ). toLocaleString () } ` );
sendFlashMessage
Send a flash transfer as a message.
Target peer (user or group)
Example:
const msgId = await core . apis . FlashApi . sendFlashMessage (
'fs_abc123' ,
{ chatType: ChatType . Private , peerUid: 'u_123456' }
);
console . log ( 'Flash message sent:' , msgId );
getFileTransUrl
Get download URL for files in a fileset.
Array of download URLs for each file
Example:
const urls = await core . apis . FlashApi . getFileTransUrl ( 'fs_abc123' , {});
urls . forEach (( url , index ) => {
console . log ( `File ${ index + 1 } : ${ url } ` );
});
createFileThumbnail
Create a thumbnail for a file.
Path to the generated thumbnail
Example:
const thumbnailPath = await core . apis . FlashApi . createFileThumbnail ( '/path/to/image.jpg' );
console . log ( 'Thumbnail created:' , thumbnailPath );
Complete Example
import { NapCatCore , ChatType } from 'napcat-core' ;
class FlashTransferManager {
constructor ( private core : NapCatCore ) {}
// Create and share a flash transfer
async shareFiles ( filePaths : string [], name : string , targetUid : string ) {
// Create thumbnail for first file if it's an image
let thumbnail : string | undefined ;
if ( filePaths [ 0 ]. match ( / \. ( jpg | jpeg | png | gif ) $ / i )) {
thumbnail = await this . core . apis . FlashApi . createFileThumbnail ( filePaths [ 0 ]);
}
// Create flash transfer
const fileSetId = await this . core . apis . FlashApi . createFlashTransferUploadTask (
filePaths ,
thumbnail ,
name
);
// Get share link
const { shareLink , shareCode } = await this . core . apis . FlashApi . getShareLinkBySetId ( fileSetId );
console . log ( `Created flash transfer: ${ name } ` );
console . log ( `Share link: ${ shareLink } ` );
console . log ( `Access code: ${ shareCode } ` );
// Send as message
await this . core . apis . FlashApi . sendFlashMessage (
fileSetId ,
{ chatType: ChatType . Private , peerUid: targetUid }
);
return { fileSetId , shareLink , shareCode };
}
// Download files from share code
async downloadFromShareCode ( shareCode : string ) {
// Get fileset ID
const fileSetId = await this . core . apis . FlashApi . fromShareLinkFindSetId ( shareCode );
// Get file info
const info = await this . core . apis . FlashApi . getFileSetInfoBySetId ( fileSetId );
console . log ( `Downloading: ${ info . filesetName } ` );
console . log ( `Files: ${ info . fileCount } ` );
// Download files
const downloadPath = await this . core . apis . FlashApi . downloadFileSetBySetId ( fileSetId );
console . log ( `Downloaded to: ${ downloadPath } ` );
return downloadPath ;
}
}
Use Cases
Temporary File Sharing
Flash transfers are perfect for sharing files that don’t need permanent storage:
// Share project files with team
const { shareLink } = await flashManager . shareFiles (
[ '/project/design.psd' , '/project/mockup.png' ],
'Design Files' ,
'u_teammate'
);
console . log ( 'Share with team:' , shareLink );
Large File Distribution
Use flash transfers for distributing large files without permanent storage:
// Share presentation materials
const files = [
'/presentation/slides.pptx' ,
'/presentation/video.mp4' ,
'/presentation/handout.pdf'
];
const result = await flashManager . shareFiles ( files , 'Presentation Materials' , 'u_client' );
File API Permanent file operations
Online File API Online file transfers