Jumoo / uSync.Complete.Issues

Public Issue tracker and roadmap for uSync.Complete
https://jumoo.co.uk/usync/complete/
2 stars 1 forks source link

Media not uploaded when using custom media folder name and/or azure storage #63

Closed deMD closed 3 years ago

deMD commented 3 years ago

Describe the bug When using uSync Exporter to export media with media files, files are exported properly, however when importing the usync package the files are not uploaded. We use Azure storage using the package https://github.com/umbraco-community/UmbracoFileSystemProviders.Azure and a custom media folder name for each environment:

<location path="media-omg">
    <system.webServer>
      <handlers>
        <remove name="StaticFileHandler" />
        <add name="StaticFileHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.StaticFileHandler" />
      </handlers>
    </system.webServer>
  </location>

Steps to reproduce Install usync complete Install UmbracoFileSystemProviders.Azure Use a custom media location Export media Import media

Expected behavior Media is uploaded to Azure storage and linked to the imported media item.

Desktop (please complete the following information):

KevinJump commented 3 years ago

Hi,

I just want to confirm i am setup right to test this.

I have two sites,

  1. Source site is standard Umbraco install no azure (standard)
  2. Target site is Umbraco site with UmbracoFileSystemProvider.Azure installed. web.config snipped for that is:
<add key="AzureBlobFileSystem.ContainerName:media" value="jumoo-test-target-media" />
<add key="AzureBlobFileSystem.RootUrl:media" value="https://jumoodev.blob.core.windows.net/" />

With this exporting from source and importing to target works. and exporting from target and importing to source works.

Am i missing any extra steps to set this up ? have i missing a thing (i suspect i have!)

deMD commented 3 years ago

Hmm for me I use the UmbracoFileSystem.Azure on both sites with the following config:

<add key="AzureBlobFileSystem.ContainerName:media" value="media-omg" /> <-- different per site
    <add key="AzureBlobFileSystem.RootUrl:media" value="https://[myAccountName].blob.core.windows.net/" />
    <add key="AzureBlobFileSystem.ConnectionString:media" value="DefaultEndpointsProtocol=https;AccountName=[myAccountName];AccountKey=[myAccountKey]" />
    <add key="AzureBlobFileSystem.MaxDays:media" value="365" />
    <add key="AzureBlobFileSystem.UseDefaultRoute:media" value="false" /> <-- Set the false because I use custom route, see container name
    <add key="AzureBlobFileSystem.UsePrivateContainer:media" value="false" />

What I notice when I check locally is that en extra subfolder is created in the storage account where it saves the images: image

I see the same behaviour on our live environments, importing using uSync uploads files to https://cms-latam.website.com/media-la/-la while adding an image via the media section uploads files to https://cms-latam.website.com/media-la. So seems like something is splitting the folder name when using uSync :(

KevinJump commented 3 years ago

for reference it looks like this is an issue inside the UmbracoFileSystemProvider.Azure project.

when you have useDefaultRoute = false, and your container name starts 'media' then there is a part of the azure file provider that cleans up the file name.

https://github.com/umbraco-community/UmbracoFileSystemProviders.Azure/blob/adff24de3422377731720b94fe60e4544ba5afbf/src/UmbracoFileSystemProviders.Azure/AzureFileSystem.cs#L911

I think it shouldn't strip the DefaultMediaRoutevalue from the string if you are not using the default media route.