API - Update Asset Volume Im trying to figure out how to move asset(s) to a different volume. Also if I move it will that affect the entries that are using the asset?

Here's what im using to target the asset:
$resourceImage = Asset::find()-&gt;volume('resourceImages')-&gt;filename($filename);

I need to move it to my productImages volume.

Thanks!
You can move them like this

$asset = Asset::find()-&gt;volume('resourceImages')-&gt;filename($filename)-&gt;one()
$folder = Craft::$app-&gt;getAssets()-&gt;findFolder(['volumeId' =&gt; X]);
Craft::$app-&gt;getAssets()-&gt;moveAsset($asset, $folder, $filename);


It won't change your relations or anything else in fact all the function does is:

/**
 * Move or rename an Asset.
 *
 * @param Asset $asset The asset whose file should be renamed
 * @param VolumeFolder $folder The Volume Folder to move the Asset to.
 * @param string $filename The new filename
 * @return bool Whether the asset was renamed successfully
 * @throws AssetLogicException if the asset’s volume is missing
 */
public function moveAsset(Asset $asset, VolumeFolder $folder, string $filename = ''): bool
{
    // Set the new combined target location, and save it
    $asset-&gt;newFilename = $filename;
    $asset-&gt;newFolderId = $folder-&gt;id;
    $asset-&gt;setScenario(Asset::SCENARIO_FILEOPS);

    return Craft::$app-&gt;getElements()-&gt;saveElement($asset);
}