Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

How to set content type of asset with API?



  • If you click on an asset in the web UI, it's possible to change the content type of the asset through a link. However, looking through the API docs, I don't see where it's possible to modify the content type of an asset through an API call. It seems that the ProGet server is doing its own check for content type as any value contained within the Content-Type header that is sent with the PUT request is ignored. For example, as a simple test, I uploaded a markdown file and set the Content-Type to text/plain and the ProGet server sets the content type to application/octet-stream. This seems to be the default value because I can upload the file via the web GUI and get the same result.

    So in the above case, it's necessary for me to correct the server but I don't see a way of doing it without having to go through the GUI. Am I missing something?


  • inedo-engineer

    Hi @joshuagilman_1054, just doing some information-gathering here, but this sounds definitely like a bug to me...

    I uploaded a markdown file and set the Content-Type to text/plain and the ProGet server sets the content type to application/octet-stream. This seems to be the default value because I can upload the file via the web GUI and get the same result.

    Can you give reproduction instructions (including the script/code), and we can use that the verify/evaluate/fix.



  • Hi @stevedennis,

    Here is the full request from Postman:

    PUT /endpoints/test/content/test.md HTTP/1.1
    X-ApiKey: <REDACTED>
    Content-Type: text/plain
    User-Agent: PostmanRuntime/7.26.10
    Accept: */*
    Postman-Token: 1f29e244-a552-49c6-88b7-87cfc293dd16
    Host: proget.mysite.io:8624
    Accept-Encoding: gzip, deflate, br
    Connection: keep-alive
    Content-Length: 24
    # My file
    This is test!
    

    This is the asset that is created:

    {
            "name": "test.md",
            "size": 24,
            "type": "application/octet-stream",
            "content": "http://proget.mysite.io:8624/endpoints/test/content/test.md",
            "md5": "a555c6bee6027254fd2dc393fc84d3fa",
            "sha1": "b5bebaad65a6407e230b0f3e2a337196a0246dd4",
            "sha256": "1d8a3f8230963f09c494c0e6156266db66d6b5a4f2491a838739164188633538",
            "sha512": "363578250ddf2d66db3a6d31a7f1b1fc3f43f09db758958fcceb0e16bf0a0ed68365e235670cba59a3157918a9001202d654264e04d8c10cd6a79bc4954bd857",
            "created": "2021-03-30T04:05:17.763Z",
            "modified": "2021-03-30T04:05:17.763Z"
        }
    

    Here are my server details:

    {
      "applicationName": "ProGet",
      "releaseNumber": "5.3.25",
      "versionNumber": "5.3.25 (Build 18)",
      "extensionsInstalled": {
        "ProGetCoreEx": "5.3.25",
        "Inedo.SDK": "1.11.0",
        "Amazon AWS": "1.11.2",
        "Azure": "1.11.1",
        "InedoCore": "1.10.3"
      },
      "serviceStatus": "OK",
      "serviceStatusDetail": null,
      "licenseStatus": "OK",
      "licenseStatusDetail": "License key is valid.",
      "replicationHealth": null
    }
    


  • Alternatively, you can use the PS module I've been developing:

    $> Install-Module Posh-ProGet
    $> Import-Module Posh-ProGet
    $> $session = New-ProGetSession -Address 'http://proget.mysite.io:8624' -ApiToken 'mytoken'
    $> $feed = New-ProGetFeedObject @{Name='test-feed';FeedType='asset';Active=$true}
    $> New-ProGetFeed $session $feed
    $> $content = "#My File \n This is a test!"
    $> New-ProGetAsset $session $feed.Name "test.md" -ContentType 'text/plain' -Content $Content
    $> Get-ProGetAssets $session $feed.Name
    
    # Name     : test.md
    # Parent   :
    # Type     : application/octet-stream
    # Content  : http://proget.mysite.io:8624/endpoints/test-feed/content/test.md
    # Created  : 2021-03-30T04:36:21.59Z
    # Modified : 2021-03-30T04:36:21.59Z
    # Size     : 27
    # md5      : 25a7e1e4f8e8c8d387f3e5dde6f6f2a6
    # Sha1     : c584e7c125d41a9a8123f69040f30673c66c97bd
    # Sha256   : 460c44334aee7966339ad4c9c749aa67b9841dcfd7d67348fc2395a7b8adf7e4
    # Sha512   : 293be0c9cfffa1c939c2b711d4165073c3efb200ed25e0adb2bf1f88d0a2343f71a62d99265aa27560630a9643124182ee9774e713bd
               c468d2014681325b8e41
    

  • inedo-engineer

    @joshuagilman_1054 that module sounds really cool!

    Anyways this is definitely enough to work with from here, so we'll schedule some time to investigate/reproduce/fix. We may be able to get it in the next next maintenance release (scheduled April 17), as the next one is a bit close (Apr 2).

    Stay tuned!


  • inedo-engineer

    @joshuagilman_1054 this is currently planned for 5.3.27 as PG-1934 (April 17) - we'll let you know if plans change!


Log in to reply
 

Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation