Пример #1
0
    public GxExternalFileInfo(string storageObjectFullname, ExternalProvider provider, GxFileType fileType)
    {
        storageObjectFullname = storageObjectFullname != null?storageObjectFullname.Replace('\\', '/') : storageObjectFullname;

        _name     = storageObjectFullname;
        _provider = provider;
        Uri result;

        if (Uri.TryCreate(storageObjectFullname, UriKind.Absolute, out result) && result.IsAbsoluteUri)
        {
            _url = storageObjectFullname;
        }
        else
        {
            if (fileType.HasFlag(GxFileType.Attribute))             //Attributes multimedia consider Storage Provider Folder
            {
                _url  = provider.GetBaseURL() + storageObjectFullname;
                _name = _url.Replace(provider.StorageUri, string.Empty);
                if (_name.StartsWith("/"))
                {
                    _name = _name.Substring(1, _name.Length - 1);
                }
            }
        }
        _fileTypeAtt = fileType;
    }
Пример #2
0
 private string GetBucket(GxFileType fileType)
 {
     if (fileType.HasFlag(GxFileType.Private))
     {
         return(privateBucketName);
     }
     return(publicBucketName);
 }
Пример #3
0
 private string GetURL(string objectName, GxFileType fileType, int urlMinutes = 60 * 24 * 7)
 {
     if (fileType.HasFlag(GxFileType.Private))
     {
         return(Signer.Sign(Bucket, StorageUtils.EncodeUrl(objectName), TimeSpan.FromMinutes(urlMinutes), HttpMethod.Get));
     }
     else
     {
         return(StorageUri + StorageUtils.EncodeUrl(objectName));
     }
 }
Пример #4
0
        private static UploadObjectOptions GetUploadOptions(GxFileType fileType)
        {
            UploadObjectOptions options = new UploadObjectOptions();

            if (fileType.HasFlag(GxFileType.Private))
            {
                options.PredefinedAcl = PredefinedObjectAcl.ProjectPrivate;
            }
            else
            {
                options.PredefinedAcl = PredefinedObjectAcl.PublicRead;
            }
            return(options);
        }
Пример #5
0
        private static CopyObjectOptions GetCopyOptions(GxFileType fileType)
        {
            CopyObjectOptions options = new CopyObjectOptions();

            if (fileType.HasFlag(GxFileType.Private))
            {
                options.DestinationPredefinedAcl = PredefinedObjectAcl.ProjectPrivate;
            }
            else
            {
                options.DestinationPredefinedAcl = PredefinedObjectAcl.PublicRead;
            }
            return(options);
        }
        private CloudBlockBlob GetCloudBlockBlob(string externalFileName, GxFileType fileType)
        {
            CloudBlockBlob blob;

            if (fileType.HasFlag(GxFileType.Private))
            {
                blob = PrivateContainer.GetBlockBlobReference(externalFileName);
            }
            else
            {
                blob = PublicContainer.GetBlockBlobReference(externalFileName);
            }

            return(blob);
        }
 private bool IsPrivateFile(GxFileType fileType)
 {
     return(fileType.HasFlag(GxFileType.Private));
 }
Пример #8
0
 private static S3CannedACL GetCannedACL(GxFileType destFileType)
 {
     return((destFileType.HasFlag(GxFileType.Private)) ? S3CannedACL.Private : S3CannedACL.PublicRead);
 }
Пример #9
0
 private static bool IsPrivateUpload(GxFileType fileType)
 {
     return(fileType.HasFlag(GxFileType.Private));
 }