// Rename renames the stored file with the specified file ID.
//
// If this operation requires a custom write deadline to be set on the bucket, it cannot be done concurrently with other
// write operations operations on this bucket that also require a custom deadline
Rename renames the stored file with the specified file ID.

If this operation requires a custom write deadline to be set on the bucket, it cannot be done concurrently with other
write operations operations on this bucket that also require a custom deadline
// Rename renames the stored file with the specified file ID . // // If this operation requires a custom write deadline to be set on the bucket it cannot be done concurrently with other // write operations operations on this bucket that also require a custom deadline
func (b *Bucket) Rename(fileID interface{}, newFilename string) error {
	ctx, cancel := deadlineContext(b.writeDeadline)
	if cancel != nil {
		defer cancel()
	}
	id, err := convertFileID(fileID)
	if err != nil {
		return err
	}
	res, err := b.filesColl.UpdateOne(ctx,
		bsonx.Doc{{"_id", id}},
		bsonx.Doc{{"$set", bsonx.Document(bsonx.Doc{{"filename", bsonx.String(newFilename)}})}},
	)
	if err != nil {
		return err
	}
	if res.MatchedCount == 0 {
		return ErrFileNotFound
	}
	return nil
}
func ( b * Bucket ) Rename ( fileID interface { } , newFilename string ) error { ctx , cancel := deadlineContext ( b . writeDeadline ) if cancel != nil { defer cancel ( ) } id , err := convertFileID ( fileID ) if err != nil { return err } res , err := b . filesColl . UpdateOne ( ctx , bsonx . Doc { { " " , id } } , bsonx . Doc { { " " , bsonx . Document ( bsonx . Doc { { " " , bsonx . String ( newFilename ) } } ) } } , ) if err != nil { return err } if res . MatchedCount == 0 { return ErrFileNotFound } return nil }
Rename renames the stored file with the specified file ID.
Rename renames the stored file with the specified file ID .