<p>I'd just use the <code>replace</code> filter to chop it off...</p>

<blockquote>
  <p><a href="https://craftcms.com/docs/templating/filters#replace" rel="nofollow">https://craftcms.com/docs/templating/filters#replace</a></p>
</blockquote>

<p>Even if you didn't know the bucket name exactly, <code>replace</code> supports regex.</p>

CC BY-SA 3.0
2016-03-01T18:37:48.870Z
2016-03-01T18:37:48.870Z
Lindsey D
<p>My plugin takes as an argument the id of an asset. So I'm starting from here:</p>

<pre><code>   $entry = craft()-&gt;elements-&gt;getElementById($entry_id); 
</code></pre>

<p>Assuming my asset has the url <a href="http://mybucket.mycompany.com/uploads/pdfs/myfile.pdf" rel="nofollow">http://mybucket.mycompany.com/uploads/pdfs/myfile.pdf</a>, how can I return just 'uploads/pdfs/myfile.pdf' from within my plugin?</p>

<plugin-development><assets>
How can I get an S3 asset's remote path minus the bucket name from within my plugin?
# How can I get an S3 asset's remote path minus the bucket name from within my plugin?

(Asked by: username_0 on 2016-03-01)

My plugin takes as an argument the id of an asset. So I'm starting from here:
   $entry = craft()->elements->getElementById($entry_id); 

Assuming my asset has the url http://mybucket.mycompany.com/uploads/pdfs/myfile.pdf, how can I return just 'uploads/pdfs/myfile.pdf' from within my plugin?

**Tags:** plugin-development, assets


---

## 1 answers

### Answer by username_1 on 2016-03-01. Score: 3

I'd just use the `replace` filter to chop it off...

> <https://craftcms.com/docs/templating/filters#replace>

Even if you didn't know the bucket name exactly, `replace` supports regex.


---

